Forums Forums Search Search Results for 'get_field'

Viewing 10 results - 61 through 70 (of 188 total)
  • Author
    Search Results

  • Anonymous
    Inactive

    Hi,

    I have a search form set which targets a custom post type and loads the results in the custom post type archive. The search is working as normal however, the infinite scrolling doesn’t seem to work and when I change the results per page it doesn’t change on the results page.

    The custom post type archive is using the standard loop like so:

    Can you help please?

                     <div class="entry-content">
    
    <div class="tender-main-wrapper">
    
     <div id="searchtenders">
    	 	<?php echo do_shortcode('[searchandfilter id="3059"]'); ?>
    </div>
    
     <div class="tender-opportunity-panel">
    
      	<?php
    
    			// Start the loop.
    			$count = 1;
    
    			while ( have_posts() ) : the_post();
    
    				echo '<div class="'.$post->ID.' tender-oppor">';
    
    				echo '<div class="tender-desc">';
    					echo '<h2>'.get_field('opportunity').'</h2>';
    					echo '<p class="lead">' .get_field('funding_organisation').'</p>';
    					echo '<p><strong>Amount available:</strong> ' .get_field('amount_available').'</p>';
    					echo '<p><strong>Geographical Coverage:</strong> ' .get_field('geographical_').'</p>';
    					echo '<p><strong>Contract Duration:</strong> ' .get_field('contract_duration').'</p>';
    					echo '<p><strong>Deadline:</strong> ' .get_field('deadline').'</p>';
    					echo '<p><strong>Other notes:</strong> ' .get_field('other_notes').'</p>';
    					echo '<a class="btn readmore-link" target="_blank" href="' .get_field('hyperlink').'">Read more</a>';
    				echo '</div>';
    
    				echo '<div class="tender-cta">';
    				echo '
    						 <a class="btn btn-primary" target="_blank" href="'.site_url().'/contact-a-bid-writer/?ref='.get_the_title().'">Contact a Bid Writer</a>';
    				echo '</div>';
    
    				echo '</div>';
    
    			// End the loop.
    			$count++;
    			endwhile;
    ?>
       </div>
    
     </div>
    #209600

    Anonymous
    Inactive

    Hi Trevor,

    Thanks so much! I understand this is outside your support and your suggestion on how I would theoretically was EXACTLY what I needed to make this happen. I was able to get this to happen following your suggestion.

    I saw some others that were trying to do this, so I wanted to post my code in case in might help someone else. This code is using the Custom query output, so this code is placed within my custom template. It’s commented and should hopefully make sense to someone who’s trying to achieve something similar. It should be noted that for this client, it made the most sense for the posts be sorted ASCENDING by DATE, rather than the default DESCENDING. I imagine if you wanted/needed to use DESCENDING, then you would need to base the foreach and conditionals off of next_post instead of prev_post:

    <div id="faqloop">
    
            <?php
            $args = array(
             'search_filter_id' => 8836
           );
            $faqs = new WP_Query($args);
            if ($faqs->have_posts() ) : $count=0;
              while ($faqs->have_posts() ) : $count++;
                $faqs->the_post();
    
                //Custom Fields
                $question = get_field( 'faq_question' );
                $answer = get_field( 'faq_answer' );
    
                // Adjacent Posts, IDs and Terms
                $prev_post = get_previous_post();
                $next_post = get_next_post();
                $next_post_id = $next_post->ID;
                $prev_post_id = $prev_post->ID;
                $prev_terms = get_the_terms( $prev_post_id, 'faq_category' );
                $terms = get_the_terms( $post->ID, 'faq_category' );
    
                // Create variable containers for the post IDs
                $term_slug = array();
                $prev_term_slug = array();
                $term_name = array();
    
                // Current tax loop
                foreach($terms as $term) {
                  $term_slug =  $term->slug;
                  $term_name =  $term->name;
                }
                //Adjacent Post tax loop
                foreach($prev_terms as $prev_term) {
                  $prev_term_slug =  $prev_term->slug;
                } ?>
    
    <?php //Echo term title if it's different than previous term OR is the last post in the loop
    if($prev_term_slug !== $term_slug || !$prev_post){ ?>
      <div class="faq-section--header <?php echo $term->slug; ?>">
       <h3><?php echo $term_name; ?></h3>
     </div>
    <?php } ?>
    
    <div class="faq-section--questions">
      <div class="faq-entry">
        <div class="faq-entry--question">
          <i class="faq-toggle"></i><span><?php echo $question; ?></span>
        </div>
        <div class="faq-entry--answer">
          <?php echo $answer; ?>
        </div>
      </div>
    </div>
    
    <?php endwhile; ?>
    <?php else: ?>
      <span data-search-filter-action='infinite-scroll-end'>No FAQs match that search or combination</span>
    <?php endif;?>
    <?php wp_reset_postdata(); ?>
    </div>
    #209353

    Trevor
    Participant

    Instead of this:

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

    this:

    $my_category_array = $sf_current_query->get_fields_html(array("_sft_category"), $args);

    And then manipulate, I think. For this you would need to find some snippets, on a site like stackexchange.

    #209339

    Anonymous
    Inactive

    Thank you so much. Now Im displaying the result counter also Im displaying the filters.

    <?php		
    		global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(840)->current_query();
    		$args = array(
    				"str" 					=> '%2$s', 
    				"delim" 				=> array(", ", " - "), 
    				"field_delim"				=> ', ', 
    				"show_all_if_empty"			=> false 
    			);
    			
    			echo $sf_current_query->get_fields_html(
    				array("_sft_category"), 
    				$args
    			);
    
    ?>

    My result is

    Genre1, Genre2, Genre3, etc…

    How I can “put” this array in div or class?

    #208613

    Trevor
    Participant

    First, make sure that you followed the guide for customization here:

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

    Then, editing the code, it would looks something like this:

    <?php if( get_field('flow_rate') ):?>
    <p>Flow Rate: <?php the_field('flow_rate'); ?></p>
    <?php endif; ?>

    Should be all you need.

    #208435

    Anonymous
    Inactive

    Hi there,

    I’d like to display the name of the active Post Meta filter. I’ll be using this to show a message when nothing in this type is available, e.g. “We currently have no “freelance” jobs available”.

    I have to note that I’m not working with any taxonomies, but rather have a Post Meta filter which I grab from advanced custom field values (which works like a charm, love the support).

    I tried this code but unfortunately nothing shows up:

    <?php
    	//Get a single fields values using labels
    	//replace <code>1526</code> with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(1860)->current_query();
    	echo $sf_current_query->get_field_string("_sft_verhouding");
    	
    ?>

    You can check the page out here. Please note it’s already sorted on “Alphahulp”

    #206182

    In reply to: Shortcodes in excerpt


    Trevor
    Participant

    I changed the code to this:

    <?php if( get_field('purchase') ):?>
    <p><?php echo do_shortcode(get_field('purchase')); ?></p>
    <?php endif; ?>
    #206079

    In reply to: Shortcodes in excerpt


    Trevor
    Participant

    Did you try wrapping that code in a do_shortcode function?

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php do_shortcode(the_field('my_custom_field')); ?></p>
    <?php endif; ?>

    I am not sure if that would work. Otherwise you may need to use PHP string functions to fetch the string as before, then split it up into before the button shortcode, the shortcode and the what comes after, and then handle them, with the shortcode being output in a do_shortcode function.

    #205982

    In reply to: Shortcodes in excerpt


    Anonymous
    Inactive

    Is the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?

    I am using Ajax to load the page. I am using standard WP audio shortcode.
    I turned Ajax off and all is good now. Thanks!

    <?php if( get_field(‘my_custom_field’) ):?>
    <p>My Custom Field Value: <?php the_field(‘my_custom_field’); ?></p>
    <?php endif; ?>

    thanks, I will try

    PS Very good support speed!

    #205978

    In reply to: Shortcodes in excerpt


    Trevor
    Participant

    Is the page loading using Ajax? If so, that will be the issue, as the player you are using needs reinitialising after an Ajax load. What player are you using?

    As to ACF fields. Let us assume it is a single value field use key is my_custom_field and the prefix required is My Custom Field Value, then the PHP is this:

    <?php if( get_field('my_custom_field') ):?>
    <p>My Custom Field Value: <?php the_field('cial_secteur'); ?></p>
    <?php endif; ?>
Viewing 10 results - 61 through 70 (of 188 total)