• Resolved Akexis

    (@akexis)


    Hello again.

    I found the hook to add custom meta to the results list which has allowed me to take some control over the results view. However, it’s using a template language <% %>, I imagine for the JavaScript filler.

    add_filter( 'wpsl_listing_template', 'custom_listing_template' );

    Is there any way to get the store post ID? What I need, in short, is to pass the value of <%= id %> to a new query.

    Is there a way to get the store post ID off of global $wpsl?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Akexis

    (@akexis)

    Nevermind. I did my own asynchronous thing to add what I needed.

    Adding an async callback option might be cool for down the road. Again, awesome plugin, easy to work with.

    Thanks!

    Hey Alex, I am trying to get ACF fields to display on the list template, Can you help me with this?

    Thread Starter Akexis

    (@akexis)

    Sure. Are you trying to add ACF fields to each store listing that populates in the results?

    Yes

    Thread Starter Akexis

    (@akexis)

    https://wpstorelocator.co/document/wpsl_listing_template/

    Adding this code to your functions file will now let you modify the output you get for search results.

    https://wpstorelocator.co/document/wpsl_frontend_meta_fields/

    This explains how you can add your meta fields to the array being returned by the JSON object.

    This is where you’re going to have to play around a bit. I think something like this should work?

    $store_fields['wpsl_acf_field_name_1'] = array( 
            'name' => 'acf_field_name_1'
    );
    
    $store_fields['wpsl_acf_field_name_2'] = array( 
            'name' => 'acf_field_name_2'
    );

    There’s a note on the page: The part after wpsl_ in the $store_fields key has to match with the name of a meta box field.

    Then in your custom template function:

    $listing_template .= "\t\t\t" . '<% if ( acf_field_name_1 ) { %>' . "\r\n";
    $listing_template .= "\t\t\t" . '<p><%= acf_field_name_1 %></p>' . "\r\n";
    $listing_template .= "\t\t\t" . '<% } %>' . "\r\n";

    I haven’t tested this, so it might need some work.

    • This reply was modified 7 years, 5 months ago by Akexis.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Adding things to the list of results’ is closed to new replies.