How to search through generated pages

MPG is a WordPress plugin that enables unlimited pages to be generated and updated, however, by default those generated pages cannot be found within your website. If you search for a keyword that is used in the generated pages it will not be part of the result because your WordPress looks for physical pages only.

The good news is that MPG has an option to show generated pages using the default search also but it needs to be configured separately and this guide explains how to do it.

🖲 Activate the participation in search

You need to allow your project to participate in the search by checking this checkbox: This setting is separate per project.

🧹 Remove the template itself from being searchable

We also recommend excluding the template itself from being searchable: This way you will be sure that your template with tags is not finable on the website to prevent results like this:

⚙️ Configure the search to match your theme's architecture

Here is the most important and the most challenging part - we need to configure search settings for them to match your theme/template. In this example, we will be using Neve theme's structure.
Go to MPG->Search Settings tab that looks like this when opened:
As you can see, we have some tags that we will be using to dynamically generate results for the search page.

To get the real structure of your current search page, you can search for anything on your website that will give you some results, which could be done by using search input on your website or by attaching ?s=sometext query to your domain. 
For example - https://themeisle.com/?s=mpg

As mentioned we will be using the Neve theme and its search page in this example so here is how the DOM looks for the rendered search page in the Neve theme:

As we can see above we have a main container that has the class ".posts-wrapper" where everything is rendered so this will be our Selector:

Your theme could have ID and not a class so in that case, you would be adding #posts-wrapper as a selector or any other name that your main container has.

Then, we see that every result found is rendered as a separate <article> element so we just need to take one of them by right-clicking on it, selecting Copy->Copy Element:
Once we have this element in our clipboard, let's go back to the MPG Search settings and Paste it there:
Now, the last thing to do is to replace all the text here with those shortcodes that we have highlighted in yellow below the text area. It's not necessary to use all of them, use only those that make sense to you and that match the structure of your current search page.

After removing all hardcoded strings and with tags only you should be having a result similar to this:

Now, you should be able to find the generated pages when searching on your website.

By the way, most of the themes, including Neve theme, do not render the main container if there are no physical results found, so if your query doesn't match any results with physical pages - no results will be given on the page because the selector that we added before won't be present on the page.
In such case, you need to create a child theme and modify the search.php template to always render the container that we're using as a selector.

You can download the Neve Child theme from HERE.

Then, take the search.php file from /wp-content/themes/neve/ and place it in your child theme and then change the content of it to this code that you can take from here:


🗂 Useful Resources

🎥 How to configure the search settings in MPG?
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.