Knowledge Base

Displaying the category titles (or taxonomy term titles) in the result title or content

After plugin version 4.14.3

The most recend plugin version supports printing taxonomy terms via the advanced title and content fields. Please read the linked documentation section on how to use them.

Older plugin versions (this works with new releases as well!)

For this task we are going to use a custom filtering function, which connects to one of the filters provided by ajax search pro.

Put the following code to your active theme/child theme functions.php file (copy from line 3 only!):
PLEASE NOTE: It is highly recommended to have a back-up before editing your site files, just in case!

Change the $taxonomy variable according to your needs to the taxonomy:

  • category – for post categories
  • post_tag – for post tags
  • product_cat – for WooCommerce product categories
  • product_tag -for WooCommerce product tags
  • etc..

..the $field variable to either ‘title’ or ‘content’ depending on which field you want to add the terms..
..the $location variable to either ‘before’ or ‘after’ depending on where to place the terms relative to the field
..the $delimiter to whatever you want between the terms.
..and the $before_output and $after_output variables to print additional text or HTML before the terms output.