Tag Info

Hot answers tagged

3

Yes of course. One of the ways to achieve this is by adding an extra category to your posts which you call 'sticky' or 'important' or something like that. For the example I will choose 'important'. To only get the important posts you can write a loop which loops through this category. For example: <?php $args = array( //arguments for the loop ...


2

There are a few errors which I want to address First of all, you should never use query_posts to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with query_posts is, it many circumstances, pagination fails Note: This function isn't meant to be used by plugins or themes. As explained later, there are ...


1

The requires are just echoing the content, you need to put ob_start(); before the if ($query->have_posts()) :, and return ob_get_clean(); after the endif;.


1

Try like this : $args = array( 'post_type' => 'car', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'your category/taxonomy name for post type car', 'terms' => 'term name/category name', 'field' => 'slug' ) ) ); $query = new WP_Query($args); $results = ...


1

This quite an opinionated question as there are many methods which you can use to reach your end goal. There are a couple of questions you should ask yourself here first, like, do I need these posts to be part of my normal blog posts, what are these posts intended for, how often will I rotate them, or will they stay for a long length of time. Based on the ...


1

<?php $args = array( 'posts_per_page' => 5, 'cat' => 2, 'tag__not_in' => array(5), // Assuming 5 is the ID for the tag 'order' => 'asc' ); $query = new WP_Query($args); while ($query->have_posts()) : $query->the_post(); ... endwhile; // don't forget to reset/restore the query wp_reset_postdata(); ?> make sure that ...


1

rearrange your code and use post_count; example: <?php $movieNumber = 1; $today = date('Ymd'); $posts = array ( 'post_type' => 'movie', 'posts_per_page' => -1, ); $loop = new WP_Query( $posts ); ?> <div id="posters<?php echo $loop->post_count; ?>"> ...



Only top voted, non community-wiki answers of a minimum length are eligible