Select posts from Category

In my opinion, you should avoid using common words like “images”. It can be confusing for the system. A previous post on SO nailed the use of images using Category ID. Here’s your edited code: <?php $your_category_ID = ‘1’ $query = new WP_Query( ‘cat=$your_category_ID’ ); if ( $query->have_posts() ) { while ( $query->have_posts() ) : … Read more

getting post data in functions.php

I got it to work by doing it this way if (is_admin() ){ $post_id = isset($_GET[‘post’]) ? $_GET[‘post’] : isset($_POST[‘post_ID’]) ; if( $post_id && in_category(‘audio’, $post_id) ){ add_action(‘admin_init’, ‘add_meta_boxes’, 1); } } The only problem with this method is that it won’t display the metabox until after you have published the post. The $post_id variable … Read more

How to show 1-5 of X Total Results

it’s been a long time, I had exact the same task and here is the solution $from = ($query->query_vars[‘posts_per_page’] * $paged) – ($query->query_vars[‘posts_per_page’] – 1); if(($query->query_vars[‘posts_per_page’] * $paged) <= ($query->found_posts)){ $to = ($query->query_vars[‘posts_per_page’] * $paged); }else{ $to = $query->found_posts; } if($from == $to){ $from_to = $from; }else{ $from_to = $from.’ – ‘.$to; } It’s not … Read more

How to define multi categories posts number

I don’t know if ther’s something similar to posts_per_category or “cat” => array( “5” => array(“posts_per_page” => “3”), but you can do it with conditionals, if you form an array with the posts ids. The problem I can see, is that you have to query all posts or set a limit by date for example, … Read more