Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

bboy8k on "Load WordPress post content into DIV using AJAX"

$
0
0

I'm really in difficulties,

I have a button:
<a href="javascript: addtocart('<?php echo get_the_ID();?>','1')" class="button add_to_cart_button product_type_simple add-to-cart">ADD TO CART</a>

And my js:

function addtocart(productid,quantity){
    jQuery.ajax({
        type:"GET",
        url:"wp-content/themes/Teafull/addcart.php",
        data:"productid="+productid+"&quantity="+quantity,
        success:function(html)
        {
			alert('Update Success');
			var sum = html;
			$("#total-cart span").text(html);
			$("#right-cart").empty();
			$("#right-cart").load("wp-content/themes/Teafull/cart-update.php");
        }
    });
}

My file cart-update.php:

<?php
/*
Template Name: Update Cart
*/
session_start();?>
<h3><span>Giỏ hàng</span></h3>
	<?php
		if($_SESSION['sizeof'] == 0){
			echo '<div class="empty-cart"><p style="color: #49aba8;">No products in your cart<p><div class="clear"></div>';
					}
		else{
				$ok = 1;
					if (isset($_SESSION['cart']))
					{
						foreach ($_SESSION['cart'] as $k => $v)
						{
							if (isset($k))
							{
								$ok = 2;
								break;
							}
						}
					}
					if($ok == 2){
							$total = 0;
							foreach ($_SESSION['cart'] as $key => $value)
							{
								$item[] = $key;
							}
							$str = implode(",", $item);
							$total =0;
							$my_query = query_posts(array('post__in' => $item,'post_type'=> 'product'));
							global $post;
							foreach ($my_query as $post) {
							   $posts_by_id[$post->ID] = $post;
							}
							foreach ($item as $id) {
								if (!$post = $posts_by_id[$id]) continue;
							   setup_postdata($post);

							   $price = mtbxr_val('price');
							   $quantity = $_SESSION['cart'][$id];	

								echo "<ul class='cart_list product_list_widget'><li>";
									echo "<a href='"; echo the_permalink(); echo "'>";
									echo the_post_thumbnail();
									echo "<p>";echo the_title(); echo"</p></a>";
									echo "<p class='clear' id='price-sidebar'><b>Price:</b> "; echo $price;
								echo "</p></li></ul>";
							}

				}
		?>
		<div class="clear"></div>
		<p class="buttons">
			<a href="http://localhost/tem5/?page_id=159" class="button">My cart →</a>
		</p>
		<div class="clear"></div>
		<?php }?>

I want when I click on the button "ADD TO CARD", div #right-cart load file cart-update.php.
When I click on the button "ADD TO CARD", the following error happen:

Fatal error: Call to undefined function query_posts() in C:\xampp\htdocs\tem5\wp-content\themes\Teafull\cart-update.php on line 32

But, If I refresh page, Fatal error doesn't happen.

Could anyone please help me how to solve this problem?


brashell on "wp_ajax_autocomplete_user and include_blog_users"

$
0
0

So I am working on editing a messaging plugin and am trying to make it so when you type who the message is to it uses the autocomplete like how it is for super admins in multisite (this is on a multisite install) and I am trying to figure out how I implement wp_enqueue_script( 'user-suggest' ); into the following forum/messenger

<h2><?php _e('New Message', 'messaging') ?></h2>
				<form name="new_message" method="POST" action="admin.php?page=messaging_new&action=process">
					<table class="form-table">
					<tr valign="top">
					<th scope="row"><?php _e('To (usernames)', 'messaging') ?></th>
                    <?php
					$message_to = isset($_POST['message_to']) ? sanitize_text_field($_POST['message_to']) : '';
					if ( empty( $message_to ) ) {
						$message_to = isset($_GET['message_to']) ? sanitize_text_field($_GET['message_to']) : '';
					}
					?>
					<td><input type="text" name="message_to" id="message_to" style="width: 95%" tabindex='1' maxlength="200" value="<?php echo $message_to; ?>" />
					<br />
It is for the message to

aminb5 on "how to add multiple Authors to a post?"

$
0
0

Hi everyone,
Hope your all doing fine.

So I have a multi author website and the authors are set to only see and edit their own posts.

I want the admin of the site to be able to assign(append) a second author(judge) to the posts so that the appended author(judge) can be able to review the post and do the actions necessary.

So far I have built a custom field which displays the authors(judges) in a dropdown menu but I don't know how to append the author(judge) to the post.

I have tried these plugins :
Co-Author
Co-Author-Plus
multiple-authors
sp-authors

and only Co-Author-Plus appends the Author to the existing Author of the post but the only problem with Co-Author-Plus is that it displays all the users in an input field... I only want the Authors which I have with the role of judge to be displayed and I want them to be displayed in a dropdown menu.

I would really appreciate it if anyone could help me with this?

Regards!

Rambomst on "Permissions error when using wp_insert_post externally"

$
0
0

I have a php script that runs outside of wordpress.

All it contains is the following code.

require_once "../wp-load.php";
$imagePost = array(
		'post_title' => 'Here',
		'post_content' => 'Content added later.',
		'post_status' => 'publish',
		'post_author' => 1,
		'tags_input' => "''",
		'post_category' => array(1),
		'post_type' => 'post'
);

$postID = wp_insert_post($imagePost, true);
die($postID);

I use to be able to run that without any issues however it now comes up with a white page and the message "Are you sure you want to do this?". I am really at a loss as to how I should fix this.

Any help is much appreciated.

theguitarlesson on "Custom post type pinging?"

$
0
0

Hi,

I know pages don't ping any ping services, only posts do.

But do custom post types ping as well?
Or do I need to implement this with get_to_ping when a custom post type publishes?

Thanks
Tom

pedro_dles on "PHP: Add translated tags to category list"

$
0
0

I have a website made from a template in WordPress, I've installed a translation plugin (qtranslate).

http://madebysylvie.be/collection

In my "photo album" page when I sort the items in the default language (english) everything works fine, however if I change to another translation (ex.french), the name of the category changes and the tagged items don't appear anymore.

Here is the PHP code that executes that function,

<ul class="filter_portfolio"> 

                <?php
                    // Get the taxonomy

                    $terms = get_terms('filter', $args);
                    // set a count to the amount of categories in our taxonomy
                    $count = count($terms);
                    // set a count value to 0
                    $i=0;
                    // test if the count has any categories
                    if ($count > 0) {
                        // break each of the categories into individual elements
                        foreach ($terms as $term) {
                            // increase the count by 1
                            $i++;

                            // rewrite the output for each category

                            $term_list .= '<li class="segment-'.$i.'"><a href="javascript:void(0)" data-value="' . $term->slug . '">' . $term->name . '</a></li>';

                            // if count is equal to i then output blank
                            if ($count != $i)
                            {
                                $term_list .= '';
                            }
                            else
                            {
                                $term_list .= '';
                            }
                        }
                        // print out each of the categories in our new format
                        echo $term_list;

                    }
                ?>

            </ul>

would like to change this block of code in order to identify the tags in the translated version. I know that the trigger is the ("data-value") parameter.

The following code let's me translate the taxonomies from the default language,

function qtranslate_edit_taxonomies(){
$args=array(
  'public' => true ,
  '_builtin' => false
);
$output = 'object'; // or objects
$operator = 'and'; // 'and' or 'or'

$taxonomies = get_taxonomies($args,$output,$operator); 

if  ($taxonomies) {
 foreach ($taxonomies  as $taxonomy ) {
     add_action( $taxonomy->name.'_add_form', 'qtrans_modifyTermFormFor');
     add_action( $taxonomy->name.'_edit_form', 'qtrans_modifyTermFormFor');        

 }
 }

}
add_action('admin_init', 'qtranslate_edit_taxonomies');
?>

Thank for helping.

Thanks4Helping on "I need to fix my old blogs, and hire someone to keep them safe. How do I proceed"

$
0
0

I have a few old blogs. They were kind of popular for a few years.

The sites kept getting hijacked. I could not keep up with it myself. I ended up giving up. Google took my sites and banned them from the search rankings etc...

I want to hire someone to fix the sites, and keep them safe. I want to relaunch the sites, but still keep the old posts, as they did get traffic when they were indexed by Google. What should I do? Thanks for any and all help.

I own the .com's
The sites are self hosted Wordpress blogs.
The blogs are mostly sports blogs.
I am hosted on BlueHost.com

kidsguide on "Settings page truble"

$
0
0

I am trying to make a plugin with a settings page, but when I upload it there was an error.

This is the HTML:

*

Plugin Name: Stops Core, Theme, and Plugin Updates

Version: 0.2

Plugin URI: http://wordpress.org/plugins/stops-core-theme-and-plugin-updates/
Author: <a href="http://profiles.wordpress.org/kidsguide"><a href="http://profiles.wordpress.org/kidsguide">Websiteguy</a></a>

Description: A Simple Wordpress Plugin That Deletes All Updating of Plugins, Themes, and Even The Wordpress Core.

Compatible with WordPress 3.6+.

*/

<?php
function msp_add_admin_menu() {
add_options_page(
'Stops Updates Page',
'Stops Updates',
'manage_options',
'msp-stops-updates-page',
'msp_display_settings_page'
);
if(isset($_POST['msp_save'])) {
add_action("admin_head-$page",'msp_save_settings_handler');
}
}
add_action('admin_menu','msp_add_admin_menu');

function edit_theme_settings() {
    if ( get_option('sold_text') == true ) { $display = 'checked'; }
    else { $display = ''; }
    update_option( 'sold_text', $display );
?>

<p>Check if you don't won't updates of it</p> 

<input type="checkbox" name='Plugin_Updates' id='Plugin' value="1" <?= checked( get_option('Plugin'), 1, false );?> />
<input type="checkbox" name='WordPress_Core_Updates' id='Core' value="1" <?= checked( get_option('Core'), 1, false );?> />
<input type="checkbox" name='Theme_Updates' id='Theme' value="1" <?= checked( get_option('Theme'), 1, false );?> />

xdp22 on "Form send to MySql problem"

$
0
0

Hello, i have problem with my code to send form values into Mysql database.

I used wordpress plugins to put php and html code in page, then my codes are simple html form and php mysql code to connect with database and send query.

I think everything should work but it doesn't

Searched many solutions on internet but i can't get it work.
It just don't sending values to database, like the form doesn't work

Someone can help me?

Here is my PHP code

if(isset($_POST['submit']))
{
~~ DB INFORMATIONS~~

$nick = $_POST['nick'];
$team = $_POST['team'];
$mail = $_POST['mail'];
$region = $_POST['region'];
$nick_query = mysql_query("SELECT <code>nick</code> FROM <code>zapisy</code> WHERE <code>nick</code> = '$nick'") or die("Error: Sprobuj ponownie pozniej.");
   $count_nick = mysql_num_rows($nick_query);
$team_query = mysql_query("SELECT <code>team</code> FROM <code>zapisy</code> WHERE <code>team</code> = '$team'") or die("Error: Sprobuj ponownie pozniej.");
   $count_team = mysql_num_rows($team_query);
    $mail_query = mysql_query("SELECT <code>mail</code> FROM <code>zapisy</code> WHERE <code>mail</code> = '$mail'") or die("Error: Sprobuj ponownie pozniej.");
   $count_mail = mysql_num_rows($mail_query);

    if($count_nick > 0){
   echo 'Lider o takim nicku zapisa? ju? inn? dru?yn?';
    }elseif($count_mail > 0){
   echo 'Ten adres e-mail zosta? ju? u?yty do zapisu innej dru?yny';
   }elseif($count_team > 0){
   echo 'Dru?yna o takiej nazwie zosta?a ju? zapisana';
}else{
$zap = mysql_query("INSERT INTO <code>zapisy</code> (<code>nick</code>, <code>team</code>, <code>mail</code>, <code>region</code>) VALUES ('".$nick."', '".$team."', '".$mail."', '".$region."')");
}
}

HTML form code

<html>
<center>
    <form method="post" action="">
        Nick Lidera: <input name="nick" ID="nick" type="text"/>
        Nazwa drużyny: <input name"team" id="team" type="text"/>
        Adres E-mail(potrzebny do potwierdzenia udziału): <input name="mail" id="mail" type="text" />
        <select name="region[]" size="3" multiple>
	<option value="euw">1</option>
	<option value="eune">2</option>
	<option value="na">3</option>
	</select>
        <input type = "submit" value = "Submit"/>

    </form>
</center>
</html>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

anmaree.annarbortees on "Hacking woocommerce plugin to show swatch color name when hovered or selected"

$
0
0

I have tried getting a hold of woocommerce directly on their forum for about a month now, and no luck. So I am coming to the Hackers to see if anyone else might be able to help me.

I have the woocommerce plugin and the woocommerce swatches and photos extension that shows swatches instead of variations as a drop down.

When hovering over the swatches and when a swatch is selected, I would like to be able to see the name of the color above the color table.

I have found this code:
<input id="attribute_pa_colors" type="hidden" value="sky" name="attribute_pa_colors"></input> in my element inspection and when I change hidden to visible I get close to what I am looking for. But exactly.

Can anyone please help me figure out how to make the names of the colors display above the color swatch table when hovered or selected.

here is a link to the page

please and thank you!

Sayed Taqui on "How to get wordpress cron job function working?"

$
0
0

I m working to randomize all the posts every day (as the date changes) by itself, and I have created a function that shuffles and returns the random post ids which I can use to show random posts.
Anyways, all I want is to schedule this function to execute everyday at 12:00.
I used WordPress function wp_schedule_event(); however that doesn’t seem to work. Has anyone worked on it before ? and know how to make it work? This is a test code I have used, m I doing something wrong?

add_filter('cron_schedules', 'my_additional_schedules');
function my_additional_schedules($schedules) {
    // interval in seconds just to test if it is working
    $schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes');
    return $schedules;
}

// schedules the wp_cron_testing
if( !wp_next_scheduled( 'wp_cron_testing' ) ) {
   wp_schedule_event( time(), 'every2min', 'wp_cron_testing' );
}

add_action( 'wp_cron_testing', 'the_wp_cron_test' );

function the_wp_cron_test() {
    echo  "Here I have my code that needs to execute.";
}

Kristoff1875 on "Send some values from WP Post to second database on submission?"

$
0
0

Hi guys,

Apologies if this is the wrong forum, I didn't quite know where to put it. I'm relatively new to wordpress and was wondering if this was possible...

The first part of what I'd like to do is to send all posts, upon submission, to a second database that holds my forum. I literally only need to post_content and post_title to be inserted to the forum posts database and the username will always be the same.

The second part of what I'd like to do, and this may not even be possible, is to return the URL of the forum post to show (in my template if possible) below the post.

Lucien Taylor on "How to modify additional profile contact values?"

$
0
0

I am trying to modify/sanitize values returned from additional profile fields which I have added using the user_contactmethods filter. I am able to validate and throw errors using the user_profile_update_errors action, but I can't find a way to filter/modify/sanitize values.

Another way of putting it: how do I take a value like Twitter Name, and add a '@' character if there isn't one - I don't need the regex, I am looking for the hook to enable me to run the function against the $_POST['twitter'] before the meta update. The order of things is quite confusing.

tasko on "wp_editor Link Question"

$
0
0

Hello,
Is it possible to hide/remove the "Or link to existing content" section from tinyMCE (link button)?

anmaree.annarbortees on "onclick div show title of div in new div"

$
0
0

How would I create this function

click on a div

show title of that div in a new div

what is the best way to do this? Java? php? both?

Can anyone help me out please! and thank yous!


sethhay on "Unique Headers for Tags/Archives/Category Templates"

$
0
0

Hello,

Trying to setup the tags/archive/category templates to call unique navigations depending on what page was visited.

For an example, the page I am on has a blue navigation and I click on the archive for 2013, this takes me to the archive page with the blue navigation. On a page with the red navigation will take me to the archive page with red navigation. I am probably over thinking this in my head but any help will help!

Gajendra on "How to create category post list like below site"

$
0
0

anybody help me thankful
Iam Trying create category post list like below site

am trying no use tell me which plugin for that and where to change

thank you

eaperu on "modifying the default 2013 header image dimensions"

$
0
0

I would like to modify the default Twenty Thirteen header image dimensions to reduce vertical space, or any other code modification that will reduce white space in the header area. I am using the Holi child theme.

SMcAfee on "When searching for my website in google "This site may be compromised" pops up"

$
0
0

When I search for my website in google "This site may be compromised" pops up under the link to my website. Does anyone know how to address this issue? Thanks!!

randomuser2000 on "Image upload and creating thumbnails functions equivalent"

$
0
0

wp_insert_attachment
wp_generate_attachment_metadata
wp_update_attachment_metadata

I am uploading images to a WordPress site. I need to do the work they do without WordPress. When WordPress making different size of images, it does for a fixed sizes or different for every image? How can i do that in pure php? And them writing to postmeta table?

[Bump deleted - please don't do that here - see the forum guidelines - these are VOLUNTEER forums so help may not be as fast as you like]

Viewing all 8245 articles
Browse latest View live




Latest Images