Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1251582
    Kade McConville
    Participant

    Hi guys,

    Added this code given to me from these forums before;

    
    add_filter( 'pre_get_posts', 'custom_search' );
    function custom_search( $query ) {
        if ( $query->is_search ) {
            $query->set( 'post_type', array( 'post','page','x-portfolio','product' ) );
        }
        return $query;
    } 

    But when validating it gives me the following errors;

    2 Parse Error add_filter( ‘pre_get_posts’, ‘custom_search’ );
    5 Lexical error at line 3, column 26. Encountered: “q” (113), after : “$” query ) {query->is_search ) {query->set( ‘post_type’, array( ‘post’,’page’,’x-portfolio’,’product’ ) );
    6 Parse Error }
    7 Lexical error at line 7, column 13. Encountered: “q” (113), after : “$” query;
    8 Parse Error }

    Any ideas on how to fix this?
    Cheers!

    #1252320
    Rad
    Moderator

    Hi Kade,

    Thanks for posting in.

    I tried that code and it’s not throwing errors on my end. Would you mind providing your site’s URL, admin and FTP login credentials? Please provide a video recording on how we can reproduce this, maybe I’m just doing it differently.

    Thanks!

    #1252375
    Kade McConville
    Participant

    Hi there,

    https://jigsaw.w3.org/css-validator/validator

    Adding the code in there comes up with errors. The CSS always appears to make my customiser global CSS code appear off too?
    Will look to follow up with a video ASAP.

    Cheers.

    #1252569
    Kade McConville
    Participant
    This reply has been marked as private.
    #1252916
    Rad
    Moderator

    Hi there,

    Now I know what you mean 🙂

    That’s a PHP code and not related to CSS. It should be added to child theme’s functions.php

    Cheers!

    #1253234
    Kade McConville
    Participant

    D’oh!

    Thanks a lot 🙂

    #1253368
    Rahul
    Moderator

    Glad we were able to help you out!

    If you have anything further to ask, kindly let us know. We’d be happy to assist you with anything.

    Thanks for choosing the X-theme.

    #1256100
    Kade McConville
    Participant

    Right,

    So adding this code, stops my forums topics from appearing…

    See issue at https://community.theme.co/forums/topic/forum-topics-not-displaying/

    #1256153
    Christopher
    Moderator

    Please keep posting on your original thread.

    Thanks.

  • <script> jQuery(function($){ $("#no-reply-1251582 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>