• Beofre, installing this plugin all posts are getting randomly. But, after installing this plugin and once save reorder, random post is not working.
    Even i deactivate or deleted the plugin, posts are not getting randomly.

    my code is below :

    $args_post=array(
    ‘post_type’ => ‘people’,
    ‘post_status’ => ‘publish’,
    ‘orderby’ => ‘name’,
    ‘order’ => ‘rand’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘people_taxonomy’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘experts’,
    ‘operator’ => ‘NOT IN’,
    )
    ),
    ‘posts_per_page’ => -1,
    ‘caller_get_posts’=> 1
    );

    $all_people_posts = get_posts($args_post);

    Please help and give a solution.
    Thanks and Regards.

    • This topic was modified 9 years, 2 months ago by vishal1988.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author nsp-code

    (@nsp-code)

    Hi,
    First of all there are errors within your arguments.. see https://codex.ww.wp.xz.cn/Class_Reference/WP_Query#Order_.26_Orderby_Parameters the Orderby should be set for ‘rand’ and Order either ASC or DESC.
    If you keep the plugin Autosort option turned On, add ‘ignore_custom_sort’ => ‘true’ within your custom query arguments to ignore the order.

    Thanks

    Thread Starter vishal1988

    (@vishal1988)

    Hello nsp-code,

    I followed your suggestion but still not working. please help. Below is my changed argument. it’s only displaying by ASC and DESC not by rnd

    $args_post=array(
    ‘posts_per_page’ => -1,
    ‘post_type’ => ‘people’,
    ‘post_status’ => ‘publish’,
    ‘orderby’ => ‘rand’,
    ‘order’ => ‘ASC’,
    ‘ignore_custom_sort’ => ‘true’,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘people_taxonomy’,
    ‘field’ => ‘slug’,
    ‘terms’ => ‘experts’,
    ‘operator’ => ‘NOT IN’,
    )
    ),

    Plugin Author nsp-code

    (@nsp-code)

    Instead
    $all_people_posts = get_posts($args_post);
    try using
    $all_people_posts = new WP_Query($args_post);

    • This reply was modified 9 years, 2 months ago by nsp-code.
    Thread Starter vishal1988

    (@vishal1988)

    Hello nsp-code,

    Thanks for your reply, but, still it doesn’t working. code i am using now
    is $all_people_posts = new WP_Query($args_post);

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘After installing this plugin, random post is not getting’ is closed to new replies.