• Resolved lazmo88

    (@lazmo88)


    Heya, we found out that exclude from search plugin won’t work when Algolia is used.

    We would like to exclude single pages/posts, however this would require custom function that hooks up with the Algolia plugin.

    That said, does the exclude from search plugin save the settings to custom field? If yes, we could use that to exclude Algolia indexing.

    Can someone advise the custom field used by the plugin?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor pronskiy

    (@pronskiy)

    Hi!

    Is this the plugin you are referring to? https://www.ads-software.com/plugins/search-by-algolia-instant-relevant-results/

    Search Exclude plugin uses options to store a list of excluded posts, I find this way more flexible.
    You can retrieve an array of excluded posts like this:
    get_option( 'sep_exclude', array() )

    Please let me know if this helps.

    Cheers!
    Roman

    Thread Starter lazmo88

    (@lazmo88)

    Thanks Roman!

    Yes that’s the plugin indeed ?? What is the expected returned value from get_options?

    function filter_post( $should_index, WP_Post $post )
    {
    if ( false === $should_index ) {
    return false;
    }

    return get_option( ‘sep_exclude’, array() ) == 1 ? false : true;
    }

    // Hook into Algolia to manipulate the post that should be indexed.
    add_filter( ‘algolia_should_index_searchable_post’, ‘filter_post’, 10, 2 );

    Plugin Contributor pronskiy

    (@pronskiy)

    It returns an array of post ids, so something like this should work:

    
    return false === array_search($post->ID, get_option('sep_exclude', array()));
    
    • This reply was modified 5 years, 11 months ago by pronskiy.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Algolia Support?’ is closed to new replies.