Pregunta

Basically i'm working on making my custom wordpress theme run on a grid style of posts in the top half of the homepage, however I would only like this code to show the sticky posts with a limited number of 5 posts, as opposed to a set number of non sticky posts?

I'm not the best with PHP, so any help would be great!

<?php
$counter = 1; //start counter

$grids = 2; //Grids per row

global $query_string; //Need this to make pagination work


/*Setting up our custom query (In here we are setting it to show 12 posts per page and eliminate all sticky posts) */
query_posts($query_string . '&caller_get_posts=1&posts_per_page=12');


if(have_posts()) :  while(have_posts()) :  the_post(); 
?>
¿Fue útil?

Solución

You should really be using WP_query for this type of function. Use this type of code:

<?php
 $args = array(
    'posts_per_page' => 1, <= This will display how many posts!!
    'post__in'  => get_option( 'sticky_posts' ), <= Stickies Posts!!
    'ignore_sticky_posts' => 1
 );
    $query = new WP_Query( $args );
?>

Hope this helps :)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top