Tag Info

New answers tagged

0

Put this in your sidebar template where you want the listing to show up. Alternatively, you could use a plugin that allows you to run php in widgets and then place directly in a widget box, but that's not always wise. <?php $categories = get_the_category(); $category = $categories[0]; $category_id = $category->cat_ID; $args = array('category__in' ...


3

You need to get the post ids from the original main query and exclude them. Then you should remove your offset from your custom query. That should do the trick. Random ordering basically ignores the offset parameter, so you need to explicitely remove the posts from the query to exclude them You can use wp_list_pluck() to get an array of post ids from the ...


2

SOLUTION: I added $titles = array(); at the top (outside the loop). Then, within the loop, I used array_push( $titles, get_the_title( $ID ) ); to collect the titles. Then I just checked the array for a matching title before displaying, like this: if ( !in_array(get_the_title( $ID ), $titles ) ) ...then do this And it works!


3

Your problem is your custom query. Do not use variables that is used by default by Wordpress. $posts and $post is Wordpress reserved global variables. Change $post to a unique variable, something like $posts_query. When using get_posts and you need to setup postdata to make use of template tags, you have no choiche but to use $post as setup_postdata() ...



Top 50 recent answers are included