Meta Boxes - Disable in Search

Support General Meta Boxes - Disable in Search

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3273
    MaxellMaxell
    Participant

    Sorry for posting this again, but I still need to find a solution for this:
    Ref topic:
    https://support.metabox.io/topic/disable-rwmb_meta-on-search-results/

    I am trying the suggested code below:

        add_filter( 'rwmb_meta', 'prefix_meta', 10, 4 );
        function prefix_meta( $meta, $key, $args, $post_id )
        {
            if ( ! is_search() )
                return $meta;
            // If this is search page, do whatever you want with the returned value $meta
            $meta = '';
            return $meta;
        }

    however it gives me following error:
    Warning: Missing argument 4 for prefix_meta()

    Sometimes it says missing argument 2 or 3 etc..

    The problem is while I am search anything, the results pick all the metaboxes of first result (at the top either its post/page) and applies on the search results page, if the first result has RED BACKGROUND selected in meta boxes, it will make the search result page as red. I need to completely ignore rwmb_meta() on search results page.

    Please help !

    regards

    #3275
    Anh TranAnh Tran
    Keymaster

    Can you post the code of the search.php page? I think it's best to don't use rwmb_meta on the search.php at all.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Meta Boxes - Disable in Search’ is closed to new replies.