Widget to show posts in the sidebar basing on its IDs

Try to replace ‘post__in’ => array($instance[‘postsToShow’]), with ‘post__in’ => explode(“,”, $instance[‘postsToShow’]), to feed the post__in with an array. Your current array looks like array(“123,456,789”) but should be like array(“123”, “456”, “789”)

SQL Bulk Move old posts by one author to another category

Try something like this: global $wpdb; $from_user = 2; $to_user = 5; $posts_table = $wpdb->prefix . ‘posts’; $users_table = $wpdb->prefix . ‘users’; $strQuery = “UPDATE `$posts_table` SET post_author = $to_user WHERE post_author = $from_user AND $posts_table.post_date < ’01/01/2013′ AND $wpdb->term_taxonomy.term_id IN (1,2,3) AND $wpdb->term_taxonomy.taxonomy = ‘category'”; echo $strQuery; $wpdb->query($strQuery); For more info please visit this … Read more

How to store array in usermeta in wordpress

Subtle difference in your name declaration, which needs to be name=”test[]”. <select name=”test[]” id=”test” multiple> <option value=”volvo”>Volvo</option> <option value=”saab”>Saab</option> <option value=”opel”>Opel</option> <option value=”audi”>Audi</option> </select> update_usermeta( $new_user, ‘test’, $_POST[‘test’] ); Edit re: your comment, $meta = get_user_meta($user_id, ‘test’); foreach ($meta as $key => $value) { echo $value; }

How to add PHP code snippet to all Post pages?

I recommend you use hooks to insert your code from functions.php instead of modifying a theme file. Otherwise you have to make the same change to the template every time you update the theme. http://codex.wordpress.org/Plugin_API/Action_Reference Many themes offers its own hooks so that you don’t have to code as much. For example, Genesis framework documentation … Read more

Open post within Foundation 3 Reveal

I’m not sure if you’re still working on this problem, and I’m using F4 so may not be exactly the same problem, but I combined Reveal with WP’s inbuilt AJAX to retrieve content. I’ll add the relevant sections of code below: Here’s the plugin code below: public function __construct() { self::$dir = plugin_dir_path( __FILE__ ); … Read more

Internal linking to posts permalink fail because of spaces and stripe at postname

Spaces are invalid characters in URLs. Your links are broken, whether the posts exist or not and regardless of whether you want the spaces or not. And uppercase/lowercase can get you in trouble too. Some servers are case sensitive so if you have a permalink to http://somesite.com/hello-world a link like http://somesite.com/Hello-World might work or it … Read more

List latest posts with least comments in WP-Admin

I managed to figure it out. So, get_posts() uses WP_Query() and we can use the example in the documentation to filter the dates. Now for the comments, that is easy, we just add the parameter ‘orderby’=>’comment_count’. Also to note, when filtering get_posts(), we will need to disable suppress_filters. Let’s filter the time first: function filter_where( … Read more