Support » Plugin: Chronological Posts » Code for just one Cat – need help please

  • Resolved madridben2

    (@madridben2)


    Hi,
    Thanks for this, it’s just what I need! But I’m just not good enough with code to know how to add the line of code that will only select posts from one category for the plugin to act on. Can you kindly give me an idea of what to add? I know how to edit the code file, just not what to add so it only reverses order for one category.

    Thanks so much.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Nick Halsey

    (@celloexpressions)

    Make a copy of the plugin with a different name (forking the plugin). Then, edit the line of code that currently says:

    
            if ( ! is_admin() && $query->is_main_query() ) {
    

    and change ti to:

    
            if ( ! is_admin() && $query->is_main_query() && $query->is_category( [CATEGORY] ) ) {
    

    Where [CATEGORY] is the category ID, name, slug, or an array of Category IDs, names, and slugs. This will only make posts chronological when you’re viewing the specified category.

    Thanks so much, just implemented this and it has worked perfectly using the cat number.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.