• Hi there,

    I am using Algolia on my site and I also used WP RSS aggregator plugin to import feed from an external source. Also they are searchable through algolia. The search works fine, ut I would like the feed link’s field to be the value of ‘wprss_item_permalink’ which is a meta key field. I added the following code to \IFNH\site\wp-content\themes\IFNH\algolia\autocomplete.php (IFNH is my child theme)
    <?php
    add_filter( ‘algolia_post_shared_attributes’, ‘vm_post_shared_attributes’, 10, 2 );
    add_filter( ‘algolia_searchable_post_shared_attributes’, ‘vm_post_shared_attributes’, 10, 2 );
    function vm_post_shared_attributes( array $attributes, WP_Post $post) {

    if($post->ID == ‘publicationsslug’)
    $attributes[‘cuslink’] = get_field( ‘wprss_item_permalink’, $post->ID );

    return $attributes;
    }

    add_filter( ‘algolia_posts_speaker_index_settings’, ‘my_posts_index_settings’ );

    function my_posts_index_settings( array $settings ) {
    $settings[‘attributesToIndex’][] = ‘unordered(cuslink)’;

    $settings[‘attributesToSnippet’][] = ‘cuslink:50’;

    return $settings;
    }
    ?>

    Also I edited the code
    jQuery.each(algolia.autocomplete.sources, function (i, config) {
    var suggestion_template = wp.template(config[‘tmpl_suggestion’]);
    sources.push({
    source: algoliaAutocomplete.sources.hits(client.initIndex(config[‘index_name’]), {
    hitsPerPage: config[‘max_suggestions’],
    attributesToSnippet: [
    ‘content:10’,
    ‘cuslink:50’
    ],

    And I am trying to get the value at
    <script type=”text/html” id=”tmpl-autocomplete-post-suggestion”>

    <#
    var linkurl = data.permalink;
    if ( data.post_type == “publicationsslug” )
    {
    linkurl = data._snippetResult[‘cuslink’].value;
    }
    #>

    But this is not working. Please help as I am quite new to PHP.

    Thanks,
    Sri

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

  • The topic ‘Get meta data’ is closed to new replies.