AnonymousInactive
Hi, finally we have done to install the function with your suggestion.
I have put the search-filter/result.php within my theme and list page is seemed to be fine though, the link displayed in the list are weird.
After choosing some checkboxes and do search, result is showed up.
And the url comes with some parameter of the search.
and, the link within result index items have the parameters of the search after its own url.
the result url is:
http://blog.grphca.jp/visca_dev2/shinsatsuken/?_sft_variety=photo,animal
and the link within the result index is:
http://blog.grphca.jp/visca_dev2/idcard/pv08-28r/?_sft_variety=photo,animal
result.php uses this code below for that:
<a href="<?php the_permalink(); ?>" title="デザイン<?php the_title(); ?>">
<?php $image = wp_get_attachment_image_src(get_field('test'), 'full');?>
<img src="<?php echo $image[0]; ?>" alt="<?php echo get_the_title(get_field('test')) ?>" />
</a>
How can I get the correct url of the result?
As I have not seen this requested before, can I assume that you have portfolio items, maybe as a Custom Post Type, and one field (probably a custom field) is the ‘external project URL’?
If that is so, it is probably a meta key. You can test this in your search form by adding a Post Meta object to the form, make it a dropdown select, find the meta key name from the list, make the choices a manual selection, not automatic (which is the default), and there is then a search button/function to find the values already stored. If they look right, then you have found the key name.
Then you need to use the standard WordPress codex method to call in a value for a custom field, like this:
<?php echo get_post_meta( get_the_ID(), 'external_project_url', true ); ?>
Depending on the actual key name. Note that fields made with specific plugins sometimes have different functions to retrieve the data, as does ACF for instance (using get_field()
).
AnonymousInactive
Hi, I have two questions.
1) I have a custom post type that has 3 associated taxonomies. I would like to enable filtering on taxonomy archives for only one of the taxonomies. Going into the reasons why would just muddy the waters. I was able to hard code this into the plugin – not ideal. If there is another way to hook into the class-search-filter-display-shortcode.php get_field function, please let me know. There don’t seem to be many filters in the code at all. Maybe this would be a good place to add one. Or, when Enabling the filtering on Taxonomy Archives in the admin panel, a dynamic conditional list of taxonomies checkboxes could show. It would only one more conditional statement in the above referenced function.
2) I would like to trigger some Google analytics event tracking. The inputs are pretty easy. Is there another js event that fires for the infinite scroll I can listen for?
Thanks for the help!
Yes, you can use get_field(). I have made many custom results.php templates for various ACF fields.
Great to speak with you Richard. Great it is sorted, and to find it was as easy as adding the Page ID number of the results page to the ACF get_field calls.
AnonymousInactive
The custom content is added in a custom field in the back-end and then called in results.php, before the loop as follows:
<?php if( get_field('luxury_holidays_content') ): ?>
<div class="masonry-layout-panel custom-content">
<?php the_field('luxury_holidays_content'); ?>
</div>
<?php endif; ?>
Strangely, if I hard code the custom content in results.php, it is always visible. However, if I call it in PHP as above, it gets removed when a search or form reset is performed.
Instead of <?php the_title(); ?>
use
<?php echo "<h1>Search result(s) for genre: " . $sf_current_query->get_field_string("_sft_genre") . "</h1>;"; ?>
Or similar.
AnonymousInactive
Hello,
this is a great plugin but i can’t figure out one thing. Is is possible to change the title of the page in any given search.
I mean when the results are loading with Ajax aso change the titlte of the page for example is user is searching for a custom field named genre and the term is rock I need on ajax to change the title of the page to “search result for genre:Rock”, if the user searches for term Jazz, then the title of the page will be “search result for genre: Jazz”
I tried using
global $searchandfilter;
$sf_current_query = $searchandfilter->get(123)->current_query();
echo $sf_current_query->get_field_string(“_sft_genre”);
but this only returns the initial genre, it doesn’t change if the user changes the filter “genre”
I would have thought you would simply use the Pods field() function, like this:
<?php echo field('resumo_objectivos');?>
But I am not familiar with the Pods plugin. This is so much easier in ACF, which would be this:
<?php echo get_field('resumo_objectivos');?>
In ACF, you can optionally specify to Post ID (using get_the_ID()
, and the format), but if yu don’t, it assumes the ID of the current post in the loop. The code example that I can see assume you will run the loop from Pods, which is not helpful.
AnonymousInactive
Hmm, it’s throwing the same error. In the original snippet there is “->get_field_string” do you think this has something to do with it?