Forums Forums Search Search Results for 'get_field('

Viewing 10 results - 71 through 80 (of 90 total)
  • Author
    Search Results
  • #99914

    In reply to: Empty result message


    Anonymous
    Inactive

    Hi Trevor,

    Thank you for your reply. I don’t know if you can call it an ‘own results template’ because in the settings you set a class, in my case .list, to show the results when you use the filter. I do have my own template for the loop to show the initial posts. Can I show you this template:

    <?php
    $custom_terms = get_terms('alfabet');
    if (!empty($custom_terms)) {
      foreach($custom_terms as $custom_term) {
      wp_reset_query();
        $args = array(
          'post_type' => 'bontvrijlijst',
          'search_filter_id' => 7242,
          'posts_per_page' => -1,
          'orderby'=> 'title',
          'order' => 'ASC',
          'tax_query' => array(
            array(
              'taxonomy' => 'alfabet',
              'field' => 'slug',
              'terms' => $custom_term->slug,
            ),
          ),
        );
    
        $loop = new WP_Query($args);
        if($loop->have_posts()) {
          echo '<div id="' . $custom_term->slug . '" class="alfabet-letter-wrap"><div class="alfabet-letter">'.$custom_term->name.'</div><ul class="members">';
          while($loop->have_posts()) : $loop->the_post();
            $company_link = get_field('url');
            echo '<li class="member"><a href="'. $company_link .'" target="_blank">'.get_the_title().'</a></li>';
          endwhile;
          echo '</ul></div>';
        }
      }
    } else {
      echo '<p><strong>Er zijn geen bedrijven die voldoen aan deze zoekopdracht. Probeer het opnieuw.</strong></p>';
    }
    ?>

    When there are no results I don’t get the ‘else’ message and in the console I see an error that the main.js file is not found. I don’t know if I can use a link in the reply message but the page is: http://joemarque.nl/dev/bvd/bontvrijlijst-test/.

    Maybe you can see what I am doing wrong.

    Best regards,
    Joeri.

    #84202

    Anonymous
    Inactive

    Hi,

    Just bought and read the docs but i’m not following here.

    This is a piece from one template file in my theme:

    <section id="events-lijst">
    
        <?php
          // the query
        $options = array(
        'post_type' => 'event',
        'posts_per_page' => 20,
        'order' => 'ASC',
        'meta_key'		=> 'taal',
    	  'meta_value'	=> 'Nederlands'
        );
        $query = new WP_Query( $options );
        ?>
    
        <?php if ( $query->have_posts() ) : ?>
    
        <div class="container">
          <div class="eventrow">
      	     <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    
               <div class="panel panel-default">
               		<div class="panel-heading">
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                  </div>
                  <div class="event-foto-sectie">
                    <?php $uitgelichte_afbeelding = get_field( 'uitgelichte_afbeelding' ); ?>
                    <?php if ( $uitgelichte_afbeelding ) { ?>
                    <a href="<?php the_permalink(); ?>"><img src="<?php echo $uitgelichte_afbeelding['url']; ?>" class="event-featured-img" alt="<?php echo $uitgelichte_afbeelding['alt']; ?>" /></a>
                    <?php } ?>
                  </div>
               		<div class="panel-body">
                    <?php
                    $dateformatstring = "l d F, Y";
                    $unixtimestamp = strtotime(get_field('datum'));
                    ?>
                    <p><strong>Datum: </strong> <?php echo date_i18n($dateformatstring, $unixtimestamp); ?><br/><strong>Locatie: </strong><?php the_field( 'locatie' ); ?></p>
                    <span class="eventuitleg"><?php the_excerpt(); ?></span>
                    <p class="bekijkevent"><strong><a href="<?php the_permalink(); ?>">Bekijk dit evenement</a> >></strong></p>
                  </div>
               	</div>
    
             <?php endwhile; ?>
    
          </div>
    
        </div>
    
      	<?php wp_reset_postdata(); ?>
    
      <?php else : ?>
        <section class="section-padding">
        <div class="container">
          <div class="row-centered">
            <div class="col-md-12 col-centered">
                <strong>Sorry, geen enkel event geprogrammeerd op dit ogenblik...</strong>
            </div>
          </div>
        </div>
        </section>
      <?php endif; ?>
    
    </section><!-- event lijst -->

    I want to put a row at the top where my query underneath is filterd on custom fields (using ACF)

    #77686

    Anonymous
    Inactive

    Hi,

    I am trying to make a filter like this: http://i.imgur.com/3IU1LEU.png (they’re all just radio buttons and a range slider).

    I have a page called “packages”. On that page I am listing all posts from the house_and_land custom post type. But honestly I’m not sure where to proceed form here.

    I don’t need to use the search field, but instead when a user arrives at the “packages” page they will immediately see all the posts listed and the search filter next to it.

    This is my code for listing all the house_and_land posts:

    $args = array(
        'posts_per_page'    => 5,
        'post_type'         => 'house_and_land'
    );
    
    $properties_query = new WP_Query( $args ); 
    
    if( $properties_query->have_posts() ):
        while( $properties_query->have_posts() ) : $properties_query->the_post();
        
            // Vars
            $estate            = get_field( 'estate' );
            $home_area         = get_field( 'home_area' );
            $min_lot_width     = get_field( 'min_lot_width' );
            $storeys           = get_field( 'storeys' );
            $bed               = get_field( 'bed' );
            $bath              = get_field( 'bath' );
            $car               = get_field( 'car' );
            $price             = get_field( 'price' );
            
        ?>
            
            <li>
                <a href="<?php echo the_permalink(); ?>">
                    <span class="estate"><?php echo get_the_title( $estate ); ?></span>
                    <span class="line-item estate min">Min lot width: <em><?php echo $min_lot_width; ?>m</em></span>
                    <span class="line-item estate area">Home area: <em><?php echo $home_area; ?>m<sup>2</sup></em></span>
                    <span class="line-item estate storeys">Storeys: <em><?php echo $storeys; ?></em></span>
                    <span class="line-item estate bed">Bed: <em><?php echo $bed; ?></em></span>
                    <span class="line-item estate bath">Bath: <em><?php echo $bath; ?></em></span>
                    <span class="line-item estate car">Car: <em><?php echo $car; ?></em></span>
                    <span class="price">From <em>$<?php echo $price; ?></em></span>
                </a>
            </li>
            
        <?php
        endwhile;
    
    endif; wp_reset_query(); 

    How do I get the search filters to work? As shown in the image (http://i.imgur.com/3IU1LEU.png) I need radio buttons for beds, baths, garages, storeys, and range sliders for price range and lot width. But the WP backend interface for S&F doesn’t make it obvious how to do that.

    Thanks in advance.

    #77443

    Trevor
    Participant

    If they are acf fields, then something like:

    <?php echo get_field('field_name'); ?>
    
    #62153

    In reply to: Doesn't referesh


    Anonymous
    Inactive

    Hi Trevor,

    My code:

    <div id="results">
                            <?php query_posts($query_string . "&meta_key=premium&orderby=meta_value"); ?>
                            <?php while (have_posts() ) : the_post(); ?>
                                <div class="<?php
                                    if (get_field('premium')) {
                                        echo 'premium';
                                    }
                                    ?> row-fluid padM marginDownS bRadiusM brightenCat resumenFicha">
                                    <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
                                        <div class="col-md-4 col-sm-6 col-xs-2 erasePad">
                                            <?php the_post_thumbnail( 'medium', array('class' => 'img-responsive bRadiusM')); ?>
                                        </div>
                                        <div class="col-md-8 col-sm-6 col-xs-10">
                                            <h4 class="text-left secondColor textSizeM">
                                                <?php if (in_category (array ('playas', 'municipios'))): ?>
                                                    <?php the_title(); ?>
                                                <?php else: ?>
                                                    <?php the_title(); ?>
                                                <?php endif ?>
                                            </h4>
                                            <p class="textSizeS mainColor esconder_xs">
                                                <?php the_field('ciudad'); ?>
                                                <?php the_field('cul_ciudad'); ?>
                                                <?php the_field('en_municipio'); ?>
                                                <?php the_field('rut_salida'); ?>
                                                <?php the_field('pn_municipios'); ?>
                                            </p>
                                            <div class="esconder_xs">     
                                                <?php the_excerpt(array('class' => 'greyFont')); ?>
                                            </div>
                                        </div>          
                                    </a>
                                </div>
                            <?php endwhile;?>
                            <div id="pagination"> 
                                <?php wp_pagenavi( ); ?>  
                            </div>
                        </div>

    #results is set to “result container”.

    And there are no javascripts errors… only two 404 getting a old image.

    Thanks

    rgds

    #57011

    In reply to: Preselecting taxonomy?


    Anonymous
    Inactive

    Ok, so I managed selecting the checkbox with some jQuery added via functions.php:

    //Select sector in posts filter
    add_action('wp_footer', 'sectorpostsfilter');
    function sectorpostsfilter(){
    	if (function_exists('get_field')) :
    		$sectorobject = get_field('taxonomy_sector');
    		$sectorid = $sectorobject->term_id;
    		if ($sectorid) : ?>
    		<script type='text/javascript'>
    			jQuery = jQuery.noConflict();
    			jQuery(function( $ ) {
    				$('.sf-item-<?php echo $sectorid; ?> input').prop('checked', true); 
    			});
    		</script><?php 
    		endif;
    	endif;
    }

    And by altering the query within the template:

    <?php 
    if (function_exists('get_field')) :
    	$sectorobject = get_field('taxonomy_sector');
    	$sectorslug = $sectorobject->slug;
    endif;
    $loop = new WP_Query( array( 'sectors' => $sectorslug ) ); 
            while ( $loop->have_posts() ) : $loop->the_post();
    			get_template_part( 'loop', 'post' );	
    	endwhile; wp_reset_postdata(); 
    ?>
    #56465

    Anonymous
    Inactive

    Thanks, I fixed that. Your plugin still adds extra paragraph tags and br tags.

    <?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">
    	
    		                   
             <div class="photo">
             <?php if (get_field('property_main_image') != '') { ?>
    			<img src="<?php the_field('property_main_image'); ?>" alt="<?php get_field('address'); ?>" />
    		<?php } else { ?>
    			<img src="/CreativeHomes/wp-content/uploads/2016/08/image-placeholder-500x500.jpg"  alt="image coming soon" />
    		<?php } ?>
    		</div>
             
                       <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 &bull; '; echo get_field('bathrooms') . ' BATHROOMS<br>';
    	
    						echo '<span class="secondline">' .  get_field('square_footage') . ' SQ FT &bull; '; 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" href="<?php echo get_field('map_it_link'); ?>"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_MapPin_Grey.png" alt="google map for location" /></a> 
      							<a target="_blank" href="<?php echo get_field('download_floorplan'); ?>"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Collateral_Grey.png" alt="brochure download" /></a>
      						</div><!--end linx-->
      					
      						<a href="<?php echo get_permalink(); ?>"><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 class="clearfix">&nbsp;</div>
    
      				</div><!--end interact-->  
      				                     
    			</div><!--end result-->
    
    		<?php
    	}
    	?>	
    	</div>				
    	
    	
    	
    	<?php
    }
    else
    {
    	echo "No Results Found";
    }
    ?>
    #56464

    Trevor
    Participant

    I can see a coding error on line 46:

    <?php if (get_field('property_main_image') != '') { ?>
    

    This if is started, but not ended. It needs to end before line 93.

    #56455

    Anonymous
    Inactive
    <?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";
    }
    ?>
    #46642

    Trevor
    Participant

    OK, the get_field('resource_date') part needs to be inside a php function. See here:

    http://php.net/manual/en/datetime.createfromformat.php

    Look at the example#2 towards the bottom.

    Modifying what they have there.

    $resource_date = DateTime::createFromFormat('Ymd', get_field('resource_date'));
    echo '<p class="lol-resource-date">' . $resource_date->format('F j, Y') . '</p>';

    That might even compress down to:

    echo '<p class="lol-resource-date">' . DateTime::createFromFormat('Ymd', get_field('resource_date'))->format('F j, Y') . '</p>';
    
Viewing 10 results - 71 through 80 (of 90 total)