Search Results for 'get_field'

Forums › Forums › Search › Search Results for 'get_field'

Viewing 10 results – 51 through 60 (of 219 total)
  • Author
    Search Results
  • #226330

    Anonymous
    Inactive

    Hi I tried looking through the forums but did not find anything about showing search/filter terms using post meta. I saw this https://searchandfilter.com/documentation/accessing-search-data/ but am not having any luck.

    I’m current using

    	echo $sf_current_query->get_fields_html(
    		array("_sft_effects", "_sfm_strain_type_checkbox"), 
    		$args
    	);

    but the _sfm_ fields do not display cleanly, it does output an array . Can you point me in the right direction?

    Thanks,

    #224682

    Anonymous
    Inactive
    
    $args = array('post_type' => 'post');
    $args['search_filter_id'] = 123;
    $query = new WP_Query($args);
    

    and

    
    <?php if ( $query->have_posts() ) : ?>
      <!– the loop –>
      <?php while ( $query->have_posts() ) : $query->the_post(); ?>
        <!– get post tags field –>
        <?php $checkbox_fields = get_field("checkbox_field_name"); ?>
    

    did my code markup wrong there whoops

    #224680

    Anonymous
    Inactive

    I got it working by using the following code from this page: https://searchandfilter.com/documentation/search-results/custom/

    `
    $args = array(‘post_type’ => ‘post’);
    $args[‘search_filter_id’] = 123;
    $query = new WP_Query($args);
    `

    and then using “the loop” and grabbing the checkbox field for each post:

    `
    <?php if ( $query->have_posts() ) : ?>
    <!– the loop –>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    <!– get post tags field –>
    <?php $checkbox_fields = get_field(“checkbox_field_name”); ?>
    `

    Then running a foreach on $checkbox_fields to display them or a certain amount of them for each result.

    Posting this here so people can use this in the future if they want to better control how their results are displayed.

    #223908

    Anonymous
    Inactive

    Sorry, Now is working but I have to reload the home page to see the results, if I don’t reload page the results are all posts.

    Any idea?

    My code:

    <?php echo do_shortcode ('[searchandfilter id="2611"]'); ?>
    		
    		<?php $args = array('post_type' => 'coche');
    		$args['search_filter_id'] = 2611;
    		$query = new WP_Query($args);?>
    
    		<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); // run the loop ?>
    			<div <?php post_class('col-sm-4 col-md-4'); ?>>
    			    <a class="thumb_rel" href="<?php echo get_permalink();?>"><?php echo get_the_post_thumbnail();?></a>
    			    <span class="posted-on">
    		            <span class="screen-reader-text">Publicado el </span>
    		            <time class="entry-date published"><?php echo get_the_date()?></time>
    		            <span class="tiempo_lectura">Tiempo de lectura <?php echo get_post_meta(get_the_ID(), 'tiempo_de_lectura', true)?>´</span>
    			    </span>
    			    <h4><a class="title_rel" href="<?php echo get_permalink();?>">
    				    <?php if( get_field('titulo_listado_3_noticias') ) { ?>
    				    	<?php the_field ('titulo_listado_3_noticias')?>
    					<?php } else { ?>
    					  <?php the_title (); ?>
    					<?php }?>
    				    </a>
    				</h4>
    			    <hr class="linea-post">
    			    <p><?php echo get_the_excerpt()?></p>
    			</div>
    		<?php endwhile; ?>
    		<?php endif; ?>
    		<?php wp_reset_query(); ?>
    #222988

    Anonymous
    Inactive

    I want to do some custom formatting depending on the used filters… I tried this:
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(69991)->current_query();
    echo $sf_current_query->get_fields_html(
    array(“_sfm_mk_quelle_affiliate_shop”),
    $args
    );

    … and: echo $sf_current_query->get_field_string(“_sfm_mk_quelle_affiliate_shop”);

    And took the field name from my search url:
    https://miriamkreativ.de/material?_sfm_mk_quelle_affiliate_shop=Creativ-Discount

    But there is nothing shown unfortunately…

    I tried one more thing (displaying the searchg term):

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(69991)->current_query();
    echo $sf_current_query->get_search_term();

    … and this works for me. So please can you help me with the first example, showing / getting the chosen “affiliate shop”-option?

    #220782

    Trevor
    Participant

    Ah, OK.

    I think you should use our Shortcode method instead. See here and also follow the guide for customising:

    https://searchandfilter.com/documentation/search-results/using-a-shortcode/

    Then, either edit the results.php file yourself, or contact me and I will edit the results.php file for you. I think the content needs to be like this:

    if ( $query->have_posts() )
    {
    	?>
    	
    	<div class="ngo-list">	
    		<div class="table">
    				
                <table>
                    <tr>
    					<th>Name</th>
    					<th>Category </th>
    					<th>Website </th>
    					<th>Learn More </th>
    				</tr>
    	
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
                    <tr>
    					<td><h5 class=""><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5></td>
    					<td><?php $term = get_field('ngo_category'); echo get_term($term)->name; ?></td>
    					<td><a href="<?php the_field('website'); ?>"><?php the_field('website'); ?></a></td>
    					<td><a href="<?php the_permalink(); ?>">View Details</a></td>
    				</tr>
    		<?php
    	}
    	echo paginate_links();
    	
    } ?>
                </table>
    					
            </div>
    	</div>	
    
    ?>
    #220392

    Trevor
    Participant

    So, if I understand you correctly, you want to conditionally show this part:

    <div class="desc"><img src="<?php the_field('image'); ?>”><p><?php the_field('business_description') ?></p></div>

    so, it would be this:

    <?php if (get_field('image')) {?>
    <div class="desc"><img src="<?php the_field('image'); ?>”><p><?php the_field('business_description') ?></p></div>
    <?php }?>

    This uses get_field to see if the image field has anything in it, and only outputs that bit if it does. I am assuming here that if the image exists, so will the description.

    I hope that helps?

    #220260

    Anonymous
    Inactive

    Yes,

    I’m trying to figure it out. But all what I try it also removes the term.

    Like, if it is “activity: ski jobs” it ends with “jobs”

    Using this code:

    <?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs

    Thank you in advance!

    #220252

    Anonymous
    Inactive

    Ok got it:

    <?php echo $sf_current_query->get_field_string(“_sft_activities”); ?> jobs

    But it displays like this activities: ski jobs

    How can I remove the “activities:”

    Thanks again for your time!

    #220031

    Trevor
    Participant

    From your original code I would have had 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
     *
     */
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(233)->current_query();
    if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) {
      echo '<div>Nothing to see here folks!</div>'; 
    } else {
    if ( $query->have_posts() )
    {
    	?>
          
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    	
    	    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		    <a href="<?php the_permalink(); ?>" alt="<?php the_title(); ?>">
    		        <h2><?php the_title(); ?></h2>
                    <?php if( get_field('summary_portfolio_description') ): ?>
                        <p><?php the_field('summary_portfolio_description'); ?></p> 
                    <?php endif; ?>		        
    		       <?php the_excerpt(); ?>
                </a>
            </article>
            
    		<?php
    	}
    
    }
    else
    {
    	echo "<span id='no-results'>No results found, please try altering your search criteria.</span>";
    }
    }
    ?>
Viewing 10 results – 51 through 60 (of 219 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.