Documentation - Getting Started - Using Conditionals for sorting apply

Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInPrint this page

Using Conditionals for sorting apply

The Advanced Post Types Order plugin offers powerful conditional logic to control when and where Custom Sorting is applied. By leveraging conditionals, you can ensure that your post order is only modified in specific scenarios, providing you with granular control over your content presentation.

What are Conditionals?

Conditionals in the context of the Advanced Post Types Order plugin are rules that define under what circumstances the automatic sorting should be applied. These conditions allow you to target specific pages, post types, URLs, or other criteria, ensuring that the sort order is adjusted only when the defined conditions are met.

advanced-post-types-order-admin-interface-conditionals

Key Features:

  • Granular Control: Apply sorting rules only under certain conditions, preventing unwanted reordering of posts in areas where a custom or different order is required.
  • Multiple Conditional Groups: You can create multiple groups of conditions, each tailored to different scenarios. This flexibility allows for highly customizable sorting logic across your website.
  • Diverse Conditional Types: Utilize a variety of condition types, including:
    • Home: Apply sorting on the homepage.
    • Page: Target specific pages by ID or slug.
    • URL: Apply conditions based on specific URLs.
    • Feed: Adjust sorting for RSS feeds or other custom feeds.

Conditional Comparisons:

Conditionals can be further refined using comparison operators, such as:

  • Is / Is Not: Apply sorting if a condition is met or not met.
  • Contains / Does Not Contain: Target elements within a condition, such as specific text in a URL.

advanced-post-types-order-conditionals-template-caller

Practical Use Cases:

  • Homepage Customization: Automatically apply a specific post order on the homepage while leaving other pages unaffected.
  • Per page Category-Specific Sorting: Use conditionals to apply different sorting rules for different pages with categories, ensuring each category page displays content in a relevant order.
  • Dynamic Landing Pages: Tailor post order for landing pages based on URL parameters or page templates, optimizing content for specific audiences or campaigns.

 

Extending Conditionals

For advanced users, the plugin allows the creation of custom conditionals via filters. This feature provides developers with the ability to define new rules and logic beyond the default options, making the plugin adaptable to any unique requirement.

For detailed instructions on how to create custom conditionals, refer to the Create a New Sort Conditional guide.