Total Builder Element Advanced Query Setting

Various Total builder modules include the ability to select what posts are being displayed, of course these are limited to the settings available (Offset, include/exclude categories, orderby, order…etc) so if you need something more advanced you can use enable the “Advanced Query” setting as shown in the screenshot below.

Once the setting is enabled you will see a new field named “Query Parameter String or Callback Function Name”. Here is where you will enter your advanced query settings and you have 2 options:

  1. You can enter a Query String
  2. You can enter a custom callback function

Query String

A query string is a string that contains parameters which looks something like this:

posts_per_page=-1&post_type=portfolio&post_status=publish&orderby=title&tax_query[0][taxonomy]=portfolio_category&tax_query[0][field]=slug&tax_query[0][terms][]=inspiration

Array Values: Since Total 5.5 you can any value that is an array can be defined using a comma separated string. So instead of doing the following:

post_type[]=post&post_type[]=portfolio

You can now simply do:

post_type=post,portfolio

Dynamic Values: The theme has various dynamic values you can use in the query, for example if you need to exclude the current post or display items from the current post author. Learn more here →

Callback Function

In Total 4.9.9 the Advanced Query setting was updated to allow you to insert a callback function name this way you could define a function to be used to return your custom Query parameters. This is great to support 3rd party plugins which have helper functions built-in for this sort of thing or for managing your queries via your child theme which can be much better.

To use a callback for your query arguments simply enter your function name in the field and then add this function to your child theme's functions.php file. Your function should have a unique name and return an array of the arguments to pass onto WP_Query.

Advanced Query Callback Function
Whitelisting Callbacks - Important! Your callback functions must be whitelisted in order for them to work. This is an important security measure.
Advanced Query Callback Function in Child Theme
Building your queries: Check out the WordPress WP_Query Codex for all the different parameters you can use in the your query.