Latest Plug-in
Latest Theme
Coming Soon!
  • Grove Wedding Theme
  • Grove Wedding Theme

    Grove is a Premium Wedding WordPress theme and will be avaiable late 2017. Demo Coming Soon!

Knowledge Base : Modify search to retrieve...

Modify search to retrieve pages and posts

← Return To Knowledge Base

All of our WordPress themes come with a search filter in place allowing only news posts to be retrieved from the database. However if you require pages or custom post types to be included in your search results then you can use the following code as base sample to customizing the return query:


function pm_ln_search_filter($query) {
    //check for a specific post type and retrieve the results. Here we are fetching the Woocommerce product post type only.
    if( isset($_GET['post_type']) ){
        if($_GET['post_type'] == 'product'){
            if ($query->is_search) {
    //check for a general search query and filter which post types to retrieve. Here we are retrieving news posts and pages  
    } else {
        if ($query->is_search) {
            $query->set('post_type', array('post', 'page'));
    return $query;

You can add this block of code to the functions.php file in the child theme provided with our themes.

    Knowledge Base Center

    Use our Knowledge base center to quickly find answers to your questions. If you can't find the answer you are looking for then post a question on our support forum instead.

    Visit our Knowledge Base Center →

Easy Social Login
keyboard_arrow_up keyboard_arrow_down

Get a 15% off discount

Subscribe to our newsletter to receive news, promotions, updates and upcoming releases.