• hi,

    I’m trying to get posts to list randomly on only one top level category page…

    I have a category called portfolio, and this has plenty of sub categories which all use the same category-4.php template file (by using the Elevate Parent Category plugin (https://pluginscatalog.com/plugins/elevate-parent-category-template.html)

    now, when viewing the main portfolio page (NOT burrowing down any deeper in the hierarchy) i want the posts displayed in a random order…

    i can’t use code such as:

    <?php $news = new WP_Query(“cat=4&orderby=rand”); ?>

    as this will just display a random load of portfolio posts from all sub sections even when i am IN a sub section (it does however give me the correct effect when i’m on the top level portfolio page)

    so basically i need code that will: (in english)

    if the category is 4, display the posts from all portfolio subsections in a random order, if not (i.e. you’re in a subsection) display as normal using a standard loop.

    I hope this makes sense? help would be much appreciated…

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘post listed randomly?’ is closed to new replies.