-
Search Results
-
hi,
i’m using the Accessing the Search Data instructions to display the search terms in the heading.
everything is working fine. the only problem is i can’t seem to find a way to remove the label and display only the search term alone.
i’m using the echo $sf_current_query->get_field_string functionwould really appreciate help on this issue.
thanks, eli.
Topic: Custom fields not displaying
I am trying to create a listing of resource documents using a custom post type and custom fields. However, my custom fields are not displaying properly when using Search & Filter.
My set-up is this:
– using custom Genesis child theme
– custom post type registered in functions.php (if I get the search working I will move the code to a plugin)
– custom fields created using Advanced Custom Fields
– custom posts created and published using the custom fields only (no native WP edit field)
– new page “Resources” published with a custom template coded to display custom fields and S&F search form; tested and displaying fine
– S&F Pro installed and configured (with Relevanssi enabled for custom field indexing).
– search form is just a basic keyword search field while testing
– Ajax disabled
– force is_search enabledMy goal is to display all available documents on initial page load. Then the user would enter a search term and the form would return relevant results on the same page and in the same container as before. (This is pretty much the same set-up as in the “Movie” demo used on the S&F demo page.)
Before enabling Relevanssi, the search was returning relevant results (when configured as a Post Type Archive – ) but only with the native WP post title, not any of the custom fields. When I switch configuration to Custom or Using Shortcode, I get a “hasn’t been configured to use shortcodes” message. My shortcodes (both when necessary) are definitely in the template used to display the page.
After enabling Relevanssi, I get another error message “attempt to assign property of non-object…” when configured as Post Type Archive or Using Shortcodes.
I suspect the problem lies in the custom loop I am using on the template file. Problem is, I have no idea how to modify this custom loop to make it work AND still query my custom post type. All Google searches lead me to how to customize the loop with WP_Query (which it already is using) or other versions that apparently S&F doesn’t like.
So my question is… could this be my issue and, if so, how do I modify the basic WP loop to query a custom post type in a manner that S&F can work with?
Or put another way…. how can I make this: http://demo.designsandcode.com/sfpro-movie-reviews/
ANy help and suggestions would be most appreciated. I have hit a brick wall and exhausted my limited PHP knowledge.
This is the code in my template file that is used for the “Resources” page:
<?php function lol_resources_custom_fields() { ?> <div class="two-thirds first"> <div id="resource-results"> <?php $args = array( 'post_type' => 'resources', 'post_status' => 'publish', 'posts_per_page' => '10' ); $resources_loop = new WP_Query( $args ); if ( $resources_loop->have_posts() ) : while ( $resources_loop->have_posts() ) : $resources_loop->the_post(); echo '<h4>' . get_field('resource_title') . '</h4>'; echo '<p>' . get_field('resource_description') . '</p>'; echo '<p>' . get_field('resource_type') . '</p>'; endwhile; wp_reset_postdata(); endif; echo do_shortcode('[searchandfilter id="456" show="results"]'); ?> </div> <!-- end #resource-results --> </div> <!-- end .two-thirds --> <div class="one-third"> <div id="resource-form"> <?php echo do_shortcode('[searchandfilter id="456"]'); ?> </div> <!-- end #resource-form --> </div> <!-- end .one-third --> <?php }