Search Results for 'the_field'

Forums › Forums › Search › Search Results for 'the_field'

Viewing 10 results – 21 through 30 (of 85 total)
  • Author
    Search Results
  • #226105

    Anonymous
    Inactive

    Hi,

    I am using a custom post type. I want to add the filter & search tools on the archive-journal.php page. The post type is called ‘journal’. Below, is my code for archive-journal.php:

    <?php echo do_shortcode('[searchandfilter id="1843"]'); ?>
      <?php echo do_shortcode('[searchandfilter id="1843" show="results"]'); ?>
    
    <?php
    if ( have_posts() ) {
    	while ( have_posts() ) {
    		the_post(); ?>
    <div class="row">
    
    <div class="col-lg-2">
    <!-- url -->
    <a href="<?php echo esc_url(the_field('url_journal')); ?>">Pdf link</a>
    </div>
    
    <div class="col-lg-3">
    <!-- title -->
    <?php	the_title(); ?>
    </div>
    
    <div class="col-lg-1">
    <!-- name -->
    <?php the_field('first_name_journal'); ?>
    <?php the_field('surname_journal'); ?>
    </div>
    
    <div class="col-lg-1">
    <!-- volume -->
    <?php the_field('volume'); ?>
    </div>
    
    <div class="col-lg-1">
    <!-- part -->
    <?php the_field('part_journal'); ?>
    </div>
    
    <div class="col-lg-1">
    <!-- month -->
    <?php the_field('month_journal'); ?>
    </div>
    
    <div class="col-lg-1">
    <!-- year -->
    <?php the_field('year_journal'); ?>
    </div>
    
    <div class="col-lg-2">
    <!-- keywords/tags -->
    <?php $post_tags = get_the_tags();
    
    if ( $post_tags ) {
        foreach( $post_tags as $tag ) {
        echo $tag->name . ', ';
        }
    } ?>
    </div>
    
    </div> <!-- close row -->
    
      <?php } // end while
    } // end if
    ?>
    

    In the settings for the plugin I have selected the following:

    – General > Search in the following post types > Journal
    – General > choose which kind of pages S & F will try to do this on > post type archives
    – General > Search form UI > I have added ‘search’ & ‘tag’.

    – Display results > Display results method: > Using a shortcode
    – Display results > Template options > I have pasted in the url of the archive-journal.php on the
    site.

    – Posts > Post status > published

    It displays ‘no results found’ & then lists all the journal posts below (which haven’t been filtered).

    How can I fix this, please?

    #224575

    Trevor
    Participant

    It does, but you need access to the PHP template that the page sues to display the results. If you are using our Shortcode display results method, then follow the guidance here:

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

    There are many examples of accessing ACF field data on the ACF forums on StackExchange. One difference is that you should use get_the_ID() to fetch the post ID of each post in the loop, and no reset is used.

    This search on our forums shows posts with some snippets:

    https://support.searchandfilter.com/forums/search/the_field/

    #224050

    Anonymous
    Inactive

    Hi!!! thanks for the support but I can’t make it work, where do I have to put that code??? If you can help me with this please.

    This is 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 class="car col-sm-6 col-md-4 wow fadeIn" data-wow-duration="1s" data-wow-delay="0.3s">
    		<a class="redirectClick" href="<?php the_permalink(); ?>">
    			<div class="item item-price" >
    			    <span class="marca"><?php the_title (''); ?></span>
    			    <span class="vehicle-finish"><?php the_field ('modelo'); ?></span>
    			    <div class="image"><img src="<?php the_post_thumbnail_url( $size ); ?>" /></div>
    			    <span class="precio categoria"><?php the_field ('precio'); ?><span class="euros-al-mes">€/mes</span><span class="iva-incluido">IVA incluido</span></span>
    			    <div class="price-canceled"></div>
    			    <div class="row categorias">
    				    <div class="col-xs-7 kilometros categoria"><img class="icono-kilometros" src="/wp-content/uploads/2019/04/icon-kilometer.svg" alt=""><?php the_field ('km_anuales'); ?><span class="km-anuales">km anuales</span></div>
    				    <div class="col-xs-5 meses categoria"><img class="icono-meses" src="/wp-content/uploads/2019/04/icon-clock.svg" alt=""><?php the_field ('meses'); ?><span class="meses">meses</span></div>
    			    </div>
    			</div>
    		</a>
    	</div>
    <?php endwhile; ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>
    #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(); ?>
    #221480

    Anonymous
    Inactive

    I’ve replaced the first section as instructed and changed the Ajax container, but still no luck.

    <?php
    /**
     * Created by PhpStorm.
     * User: jason
     * Date: 9/13/19
     * Time: 9:48 AM
     * Template Name: Job Board
     */
    get_header(); ?>
        <main id="job-board">
            <section class="job-board-search job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image', 'option'); ?>);">
                <div class="site-container narrow">
                    <fieldset class="form big">
    					<?php echo do_shortcode('[searchandfilter id="218"]'); ?>
                    </fieldset>
                </div>
            </section>
            <section class="main" id="jobs">
                <div class="site-container">
    
                    <div class="ad top"></div>
                    <div class="job-board-filters-wrapper">
                        <div id="job-board-filters" class="job-board-filters filter">
                            <h3 class="filters-heading">Job Filters</h3>
                            <a id="job-filter-toggle">
                                <svg viewBox="0 0 24.76 24.76">
                                    <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                                </svg>
                            </a>
                            <div class="job-board-filters-inner">
    							<?php echo do_shortcode('[searchandfilter id="220"]'); ?>
                            </div>
                        </div>
                        <div class="job-help">
                            <h3 class="filters-heading">Need Help?</h3>
                            <a id="job-help-toggle">
                                <svg viewBox="0 0 24.76 24.76">
                                    <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                                </svg>
                            </a>
                            <div class="job-help-inner">
                                <ul>
                                    <li><a href="#">How to Post a Job </a></li>
                                    <li><a href="#">Help for Job Seekers </a></li>
                                </ul>
                            </div>
                        </div>
                        <div class="ad left"></div>
    
                    </div>
    
    				<?php
    				$args['search_filter_id'] = 220;
    				$query = new WP_Query($args);
    				?>
                    <div class="job-board-results-wrapper">
                        <div class="mobile-table">
    						<?php
    						if($query-> have_posts() ): ?>
                            <table class="job-board-results grid">
                                <thead>
                                <tr>
                                    <th class="title">Title & Organization</th>
                                    <th class="function">Job Function</th>
                                    <th class="type">Type</th>
                                    <th class="date">Date Posted </th>
                                </tr>
                                </thead>
                                <tbody>
    
                                    <?php while($query->have_posts() ): ?>
                                        <?php $query->the_post(); ?>
                                        <?php
                                            $date = get_the_date('M j, Y');
                                            $name = get_the_company_name();
                                            $serviceAreas = get_the_terms( get_the_ID(), 'service_area' );
                                            $jobFunctions = get_the_terms( get_the_ID(), 'job_function' );
                                            $jobType = get_the_terms( get_the_ID(), 'job_type' );
                                        ?>
    
                                        <tr class="single-job-result">
                                            <td>
                                                <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                                <p><?php echo $name; ?></p></td>
                                            <td>
                                                <?php if($jobFunctions): ?>
                                                <ul>
                                                    <?php foreach($jobFunctions as $jobFunction): ?>
                                                    <li><?php echo $jobFunction->name; ?></li>
                                                    <?php endforeach; ?>
                                                </ul>
                                                <?php endif; ?>
                                            </td>
                                            <td>
                                                <?php echo $jobType[0]->name; ?>
                                            </td>
                                            <td>
                                                <?php echo $date; ?>
                                            </td>
                                        </tr>
    
                                        <?php endwhile;?>
                                    <?php else: ?>
                                       <div data-search-filter-action='infinite-scroll-end'>
                                    <h4>No results found</h4>
                                       </div>
                                    <?php endif;
                                    wp_reset_postdata();
                                ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </section>
        </main>
    <?php get_footer();
    
    #221472

    Trevor
    Participant

    I can see that you have echoed both forms on the page. This may cause issues (but not the one you describe I think).

    I suspect that the problem is the HTML structure. I think it should start like this:

    <?php
    /**
     * Created by PhpStorm.
     * User: jason
     * Date: 9/13/19
     * Time: 9:48 AM
     * Template Name: Job Board
     */
    get_header(); ?>
    <main id="job-board">
    	<section id="job-board-search" class="job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image'); ?>);">
    		<div class="site-container narrow">
    			<fieldset class="form big">
    				<?php echo do_shortcode('[searchandfilter id="218"]'); ?>
    			</fieldset>
    		</div>
    	</section>
    	<section class="main" id="jobs">
    		<div class="site-container">
    
    			<div class="ad top"></div>
                <div class="job-board-filters-wrapper">
                    <div id="job-board-filters" class="job-board-filters filter">
                        <h3 class="filters-heading">Job Filters</h3>
                        <a id="job-filter-toggle">
                            <svg viewBox="0 0 24.76 24.76">
                                <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                            </svg>
                        </a>
                        <div class="job-board-filters-inner">
                            <?php echo do_shortcode('[searchandfilter id="220"]'); ?>
                        </div>
                    </div>
                    <div class="job-help">
                        <h3 class="filters-heading">Need Help?</h3>
                        <a id="job-help-toggle">
                            <svg viewBox="0 0 24.76 24.76">
                                <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                            </svg>
                        </a>
                        <div class="job-help-inner">
                            <ul>
                                <li><a href="#">How to Post a Job </a></li>
                                <li><a href="#">Help for Job Seekers </a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="ad left"></div>
    
                </div>
    
                            <?php
                                $args['search_filter_id'] = 220;
                                $query = new WP_Query($args);
    ?>
                <div class="job-board-results-wrapper">
                    <div class="mobile-table">
    <?php
                                if($query-> have_posts() ): ?>
                        <table class="job-board-results grid">
                            <thead>
                                <tr>
                                    <th class="title">Title & Organization</th>
                                    <th class="function">Job Function</th>
                                    <th class="type">Type</th>
                                    <th class="date">Date Posted </th>
                                </tr>
                            </thead>
                            <tbody>
    
                                    <?php while($query->have_posts() ): ?>

    BUT, the ending parts to table and the job-board-results div might then need to be moved, I am not sure. I think the Ajax Container should be .job-board-results-wrapper

    #221368

    Anonymous
    Inactive

    I echoed the shortcode. Full template file below for reference. (Thanks for your responses, by the way.)

    <?php
    /**
     * Created by PhpStorm.
     * User: jason
     * Date: 9/13/19
     * Time: 9:48 AM
     * Template Name: Job Board
     */
    get_header(); ?>
    <main id="job-board">
    	<section id="job-board-search" class="job-search-menu background-image" style="background-image: url(<?php the_field('search_form_background_image'); ?>);">
    		<div class="site-container narrow">
    			<fieldset class="form big">
    				<?php echo do_shortcode('[searchandfilter id="218"]'); ?>
    			</fieldset>
    		</div>
    	</section>
    	<section class="main" id="jobs">
    		<div class="site-container">
    
    			<div class="ad top"></div>
                <div class="job-board-filters-wrapper">
                    <div id="job-board-filters" class="job-board-filters filter">
                        <h3 class="filters-heading">Job Filters</h3>
                        <a id="job-filter-toggle">
                            <svg viewBox="0 0 24.76 24.76">
                                <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                            </svg>
                        </a>
                        <div class="job-board-filters-inner">
                            <?php echo do_shortcode('[searchandfilter id="220"]'); ?>
                        </div>
                    </div>
                    <div class="job-help">
                        <h3 class="filters-heading">Need Help?</h3>
                        <a id="job-help-toggle">
                            <svg viewBox="0 0 24.76 24.76">
                                <path class="cls-1" d="M10,.5a.5.5,0,0,1,.5-.5h3.87a.5.5,0,0,1,.5.5V10h9.44a.5.5,0,0,1,.5.5v3.87a.5.5,0,0,1-.5.5H14.82v9.44a.5.5,0,0,1-.5.5H10.45a.5.5,0,0,1-.5-.5V14.82H.5a.5.5,0,0,1-.5-.5V10.45A.5.5,0,0,1,.5,10H10Z"/>
                            </svg>
                        </a>
                        <div class="job-help-inner">
                            <ul>
                                <li><a href="#">How to Post a Job </a></li>
                                <li><a href="#">Help for Job Seekers </a></li>
                            </ul>
                        </div>
                    </div>
                    <div class="ad left"></div>
    
                </div>
                <div class="job-board-results-wrapper">
                    <div class="mobile-table">
                        <table class="job-board-results grid">
                            <thead>
                                <tr>
                                    <th class="title">Title & Organization</th>
                                    <th class="function">Job Function</th>
                                    <th class="type">Type</th>
                                    <th class="date">Date Posted </th>
                                </tr>
                            </thead>
                            <tbody>
    
                            <?php
                                $args['search_filter_id'] = 220;
                                $query = new WP_Query($args);
    
                                if($query-> have_posts() ): ?>
    
                                    <?php while($query->have_posts() ): ?>
    
                                        <?php $query->the_post(); ?>
                                        <?php
                                            $date = get_the_date('M j, Y');
                                            $name = get_the_company_name();
                                            $serviceAreas = get_the_terms( get_the_ID(), 'service_area' );
                                            $jobFunctions = get_the_terms( get_the_ID(), 'job_function' );
                                            $jobType = get_the_terms( get_the_ID(), 'job_type' );
                                        ?>
                                        <tr class="single-job-result">
                                            <td>
                                                <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                                <p><?php echo $name; ?></p></td>
                                            <td>
                                                <?php if($jobFunctions): ?>
                                                <ul>
                                                    <?php foreach($jobFunctions as $jobFunction):
    
                                                        ?>
                                                        <li><?php echo $jobFunction->name; ?></li>
                                                    <?php endforeach; ?>
                                                </ul>
                                                <?php endif; ?>
                                                </td>
                                            <td><?php echo $jobType[0]->name; ?></td>
                                            <td><?php echo $date; ?></td>
                                        </tr>
    
                                    <?php endwhile;?>
                                <?php else: ?>
                                   <div data-search-filter-action='infinite-scroll-end'>
                                <h4>No results found</h4>
                                   </div>
                                <?php endif;
                                    wp_reset_postdata();
                            ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
    
    	</section>
    
    </main>
    <?php get_footer();
    
    #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>	
    
    ?>
    #220699

    Anonymous
    Inactive

    Hi,

    I try to display the result with ajax, but even if I didn’t make a search the query show me only one result and it’s look like it’s the last one.

    https://intoinc.mebdev.ca/realisation/

    And the ACF fields doesn’t work.

    Here is my query:

    <?php
    
    		echo do_shortcode('[searchandfilter id="256"]');
    
    		$loop = array('post_type' => 'realisations','posts_per_page' => 6);
    		$args['search_filter_id'] = 256;
    		$query = new WP_Query($args); ?>
    
    		<div class="results">
    			
    				<?php if ( $query->have_posts() ) :
    					while ( $query->have_posts() ) : $query->the_post(); ?>
    						<?php the_title(); ?><br />
    						<?php the_field('annee'); ?><br />
    						<?php the_field ('adresse'); ?><br />
    						<?php the_content(); ?>
    					<?php endwhile; 
    				endif; ?>
    
    		</div>

    Display results method: Custom
    Result URL: https://intoinc.mebdev.ca/realisation
    Load results using Ajax?: check
    Make searches bookmarkable?: unchek
    Only use Ajax on the results page?: uncheck
    Ajax Container: .results

    Thank you

    #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?

Viewing 10 results – 21 through 30 (of 85 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.