Forums Forums Search & Filter Pro Unable to correctly populate search results with custom field data

Viewing 9 posts - 1 through 9 (of 9 total)
  • Anonymous
    #58886

    First off, thank you for the plugin, it is tremendous.

    I am currently having issues getting the search results to work correctly with a modified/custom layout for results.php page.

    We are currently using pods to create some custom post types which have information such as game categories and game thumbnails etc. We can get the search results to work when using the regular results page just fine, but the problem is that the standard results page does not show the needed information.

    When we modify the results page to be able to echo in the pods custom fields, the results page returns pretty much every entry in the custom post type. In other words, if we have 10 total entries in the custom post type, and the search should return only 3, it returns all 10.

    I’m pretty sure that the problem is the code we are using to pull in the pods custom fields, I have a feeling it is overriding the search results in someway and just doing it’s own loop. Can you help?

    Trevor
    #58919

    What S&F Display Results method are you using? The shortcode method gives you a custom results template to play with. Check the documentation for how to start using that template:

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/#Customising_the_Results

    Trevor
    #58921

    Ah, but reading another post I see you already knew that 😉 So, for now, Are you using the Shortcode method?

    Anonymous
    #59040

    Yes. We are using a shortcode.

    Our setup is that we have some custom post types made in pods with custom data fields in each post. Search and Filter can return and filter the results fine using the standard results.php template. When we copy the results.php and rename it to be used as a custom results page, it works fine too.

    However, when we try to customize the results page by creating a custom layout, it does not return the datafields. I have a feeling that I’m doing something really obtuse.

    To be more precise, we have a custom pods post type which is identified as ‘game_site’ without the quotes. In this post type, we have a field called “game_type” which is named “game type”. If I wanted to return this specific field as an h2 tag using php echo, how would I do that?

    Trevor
    #59042

    Have you checked the pods documentation?

    Anonymous
    #59054

    Actually, I found something that looks like it works.

    <?php echo get_post_field('game_name', $post_id); ?>

    This basically looks like it will echo the value in that particular field for that particular post.

    It’s a bit confusing since I’m by no means a php expert, and anything related to the appropriate search terms returns a million things about getting post meta stuff, which didn’t work for me (probably since I have no clue about this stuff but the examples looked kinda appropriate).

    Anonymous
    #59056

    BTW, the solution in the pods documentation would be great for a static page, but on a search results page it basically “over wrote” the search results and would display all of the custom post type entries (ie, if there were 50 game sites total, and the search should only show 30, when implementing the pods code within the return.php along side the other code it would return all 50)

    Trevor
    #59071

    So, did you manage to fix this or is it still broken?

    Anonymous
    #59075

    Yes, doing

    <?php echo get_post_field('game_name', $post_id); ?>

    fixed the issue, it can be closed.

Viewing 9 posts - 1 through 9 (of 9 total)