WordPress 2.8.5 & ‘Responsive Twenty Ten’ – error

home_url() function is implemented in WordPress since version 3.0.0, and you are using version 2.8.5. To fix this error edit wp-content/themes/twentyten 3/header.php file – replace: home_url(); with: ‘http://’.$_SERVER[“SERVER_NAME”] This is hotfix, and i’m afraid you will receive more errors like this. “Responsive Twenty Ten’ are compatible with 2.8+” – as you see it’s not true … Read more

Passing POST data from one WP post to another

You need to register the query var so it doesn’t get stripped by WP. Add this to your functions.php file. function foo_add_query_var($vars) { $vars[] = ‘discount’; return $vars; } add_filter(‘query_vars’, ‘foo_add_query_var’); To call this in your template, simply use the following: $discount = get_query_var(‘discount’);

plugins_url() incorrectly returns a url with www subdomain

You can try to override it by using the following in config.php and see if it works as it will update your database, doing so will make it unable to be changed in your admin (it will be greyed out). define(‘WP_SITEURL’, ‘http://example.com/’); And some alternative definitions, http://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29 If that doesn’t work, I would check your … Read more

Output data like WP’s plugin installer/updater

Yes, WordPress uses output buffering for displaying these messages. There’s a nifty function you can use within your loop called show_message() which utilizes wp_ob_end_flush_all(); function show_message($message) { if ( is_wp_error($message) ){ if ( $message->get_error_data() ) $message = $message->get_error_message() . ‘: ‘ . $message->get_error_data(); else $message = $message->get_error_message(); } echo “<p>$message</p>\n”; wp_ob_end_flush_all(); flush(); } You might … Read more

Count total number of post in foreach loop

Edit: Re-reading your question I noticed I may have mixed some things up, but the point remains that you should combine these separate queries performed inside the loop, by using variables inside the loop to create a comprehensive list of the query arguments that you can use to perform one query outside the loop. I’ve … Read more

How do I list the_tags() into HTML data-attribute

Use json_encode(): <li class=”griditemleft” data-tags=”<?php $posttags = get_the_tags(); $data = array(); foreach($posttags as $tag) { $data[] = $tag->name; } echo json_encode( $data ); Later, in your JavaScript, iterate over the li items and for each item use: // get an array of tag names with jQuery’s parseJSON() var itemtags = $.parseJSON( item.data(‘tags’) ); See jQuery … Read more