AnonymousInactive
Would this go in functions.php or in /search-filter/results.php?
AnonymousInactive
Hello,
Issue:
I have a client site that has two languages with polylang and a form in each language (this, i do not know if it is correct) that should show the results of a taxonomy in a custom post type. In Spanish language everything works fine, but when going to the other language and filtering the content by title, it ends up showing both the form and the content in Spanish.
Details that may help:
site link
I have a custom post type called activities and a hierarchical taxonomy called activity_type, common to both languages but with different posts in each.
The two forms are configured by shortcode and I have three templates, one called results.php (in the local folder search-filter) that gives the format of the results, and other two (activities.php and results-search.php) I practically have the same code and I really do not know if they are needed (at least one of them) because results-search.php is the redirect of activities.php and I am using ajax.
In activities.php I have a wp_query that sets the language of the query in your $ args but does not solve the problem.
The shortcode is conditionally charged according to the language of the site:
<? Php if (get_bloginfo ('language') == 'es-ES'):?>
<H3> Buscador </ h3>
<? Php echo do_shortcode ('[searchandfilter id = "928"]');?>
<? Php else:?>
<H3> Cercador </ h3>
<? Php echo do_shortcode ('[searchandfilter id = "930"]');?>
<? Php endif?>
I do not know if this influences the error and it is not the right way to work, but I do not know what to do.
One last question is whether this plugin will work in multisite.
Many thanks and congratulations for this plugin.
Regards.
The grid I made using our results.php for Enfold was this:
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link http://www.designsandcode.com/
* @copyright 2015 Designs & Code
*
* Note: these templates are not full page templates, rather
* just an encaspulation of the your results loop which should
* be inserted in to other pages by using a shortcode - think
* of it as a template part
*
* This template is an absolute base example showing you what
* you can do, for more customisation see the WordPress docs
* and using template tags -
*
* http://codex.wordpress.org/Template_Tags
*
*/
if ( $query->have_posts() )
{
$gridTotalPostCount = $query->found_posts;
?>
Found <?php echo $gridTotalPostCount; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<div data-autoplay="" data-interval="5" data-animation="fade" data-show_slide_delay="90" class="avia-content-slider avia-content-grid-active avia-content-slider1 avia-content-slider-odd avia-builder-el-2 el_after_av_textblock avia-builder-el-last " itemscope="itemscope" itemtype="https://schema.org/Blog">
<div class="avia-content-slider-inner">
<?php
$gridRowPostCount = 1;
while ($query->have_posts())
{
$query->the_post();
if ( $gridRowPostCount == 1 ) {?>
<div class="slide-entry-wrap">
<?php } ?>
<article class="flex_column av_one_third <?php if ( $gridRowPostCount == 1 ) echo 'first';?>" itemscope="itemscope" itemtype="https://schema.org/BlogPosting" itemprop="blogPost">
<?php
if ( has_post_thumbnail() ) {
?><a data-rel="slide-1" class="slide-image" title="" href="<?php the_permalink(); ?>"><?php
the_post_thumbnail("portfolio");
echo '</a>';
}
?>
<h3 class="slide-entry-title entry-title" itemprop="headline"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<div class="slide-meta"><time class="slide-meta-time updated" itemprop="datePublished"><?php the_date(); ?></time></div>
</article>
<?php if ( ( $gridRowPostCount == 3 ) || ( $gridRowPostCount == $gridTotalPostCount ) ) {?>
</div>
<?php }
$gridRowPostCount++;
if ( $gridRowPostCount == 4 ) $gridRowPostCount = 1; ?>
<?php
}
?>
</div></div>
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
}
else
{
echo "No Results Found";
}
?>
I presume you refer to using the Shortcode Display Results option? That method uses our own results.php template, which you could edit to make your own grid, if you have the coding skills. However, what theme are you using? Does it have a (posts) grid system, or maybe you have Visual Composer plugin?
AnonymousInactive
I got everything working from Toolset Type plugin (for adding taxonomy to pages) and the included documentation on shortcode results. Having some styling issues but looking into the results.php file. Thank you for a well documented plugin.
With the shortcode method, the URL re-write is not possible (it is possible only with The Post Type Archive/WooCommerce Display Results Method). This is a feature planed for V3 (being written now, release later in 2017).
You can access the current query by adding code to the results.php file.
I am unable to code this for you, but if you search the forum for this string sf_current_query
, you will find some examples.
A lot of that you don’t need. You need to be careful of the type of field you are getting. For example, arrays are different. The ACF online manual is a big help. Below is an example results.php file that gets ACF fields and uses them:
<?php
/**
* Search & Filter Pro
*
* Sample Results Template
*
* @package Search_Filter
* @author Ross Morsali
* @link http://www.designsandcode.com/
* @copyright 2015 Designs & Code
*
* Note: these templates are not full page templates, rather
* just an encaspulation of the your results loop which should
* be inserted in to other pages by using a shortcode - think
* of it as a template part
*
* This template is an absolute base example showing you what
* you can do, for more customisation see the WordPress docs
* and using template tags -
*
* http://codex.wordpress.org/Template_Tags
*
*/
if ( $query->have_posts() )
{
?>
Found <?php echo $query->found_posts; ?> Results<br />
Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />
<div style="width:100%;">
<?php
while ($query->have_posts())
{
$query->the_post();
?>
<div class="result">
<?php if (get_field('property_main_image') != '') { ?>
<img />" alt="" width="400px" />
<div class="status"><?php echo get_field('status'); ?></div>
<div class="details">
<?php
echo '<h4>$' . get_field('price') . ' </h4>';
echo '<p>' . get_field('address') . '<br>';
echo get_field('city') . ', '; echo get_field('state'); echo get_field('zip') . '</p>';
echo '<p class="spex">' . get_field('bedrooms') . ' BEDROOMS | '; echo get_field('bathrooms') . ' BATHROOMS<br>';
echo '<span class="secondline">' . get_field('square_footage') . ' SQ FT | '; echo get_field('garages') . ' CAR GARAGE</span>';
echo '<span>MLS# ' . get_field('MLS') . '</span></p>';?>
<div class="linx">
<a href="#"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Photos_Grey.png" alt="see photo gallery" /></a>
<a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_MapPin_Grey.png" alt="google map for location" /></a>
<a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Collateral_Grey.png" alt="brochure download" /></a>
</div><!--end linx-->
<a>"><img src="/CreativeHomes/wp-content/uploads/2016/08/details-button.png" width="122" alt="details" /></a>
</div><!--end details-->
<div class="interact">
<span><?php the_favorites_button($post_id, $site_id); ?></span>
<span><img src="/CreativeHomes/wp-content/uploads/2016/08/check-icon.jpg" />Compare</span>
<span><?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>Share</span>
</div><!--end interact-->
</div><!--end result-->
<?php
}
?>
</div>
<?php
}
else
{
echo "No Results Found";
}
?>
AnonymousInactive
The reason is that I can easily change design results.php.
What method would you recomend me?
Hi Marcel
What theme do you use, and do you have Visual Composer. Otherwise you must edit the results.php file, after you make a copy of it, as described here.
The results.php template that this method uses is user editable/customizable, see here:
https://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/#Customising_the_Results
It uses HP to render elements/data, and the code is taken form the WordPress Codex. In you case you need to use this:
You need to be using the get_attachment_url, I think. See here:
https://codex.wordpress.org/Function_Reference/wp_get_attachment_url
Instead of the permalink. Exactly how to do this you may have to experiment with. The WP Codex will give some examples, as will the WordPress StackExchange.