• How do I exclude the ML-slider post_type when searching on frontend. Because everytime I search a keyword if that keyword has the same name in Meta Slider Title it will be included in the search result with no content and no url.

    Example:
    I search the keyword “dogs” and I have a metaslider name “dogs”, the ml-slider is included from the search result and no url. When clicked it returns “NO Page Found” because it’s an ml-slider not a post.

    I noticed in the database Posts Table all metaslider slides are created under this table with a post_type = ml-slider.

    Can you guys help me with this?

    https://www.ads-software.com/plugins/ml-slider/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter kidcajes

    (@kidcajes)

    Hello is there anyone who can help? Please?

    Thread Starter kidcajes

    (@kidcajes)

    Matchalabs? anyone?

    You can customize your theme search query for excluding post_type ‘ml-slider’ from there.
    Try these may be its works.

    Hi kidcajes,

    Apologies for the delay getting back to you. The ‘ml-slider’ post type should be excluded from search results by default. Are you using a search plugin, or just the default search built into WordPress?

    Regards,
    Tom

    Thread Starter kidcajes

    (@kidcajes)

    @sprytechies
    Thank you but i already tried that one but doesn’t work. I put that one on

    @matchalabs
    I’m using the default wordpress search. I even tried using my templates search function and it returns the same by displaying first the ML Slider post without a link (when the keyword matches the slider name).

    I hope you can help me with this one. And here is the function I added in my themes function.php

    //Exclude ML Slider from search
    function remove_ml_slider() {
    global $wp_post_types;
    if ( post_type_exists( ‘ml-slider’ ) ) {
    // exclude from search results
    $wp_post_types[‘ml-slider’]->exclude_from_search = true;
    }
    }
    add_action( ‘init’, ‘remove_ml_slider’, 99 );

    Thread Starter kidcajes

    (@kidcajes)

    This is my templates query statement:

    $querystr = “
    SELECT $wpdb->posts.*
    FROM $wpdb->posts
    WHERE 1=1 AND ((lower($wpdb->posts.post_title) like ‘%$s%’))
    AND (post_status = ‘publish’)
    ORDER BY $wpdb->posts.post_date DESC
    LIMIT $limit;
    “;

    How do I exclude ml-slider from here? Please anyone?

    Thank you!

    Hi,

    After “AND (post_status = ‘publish’)” you’ll need to add something like this:

    AND (post_type !='ml-slider')

    (untested, I suggest using WP_Query or get_posts if possible instead of a raw sql query!)

    Regards,
    Tom

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to exclude ML-Slider from a search result’ is closed to new replies.