Forums Forums Search Search Results for 'get_field'

Viewing 10 results - 141 through 150 (of 188 total)
  • Author
    Search Results
  • #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";
    }
    ?>
    #56017

    Trevor
    Participant

    In PHP you need to take the string and modify it. The first thing is to remove the Location: string. So, you use the PHP Search function to find the :, like this:

    $return_string = $sf_current_query->get_fields_html(array("_sft_locatie");
    $colon_pos = strpos($return_string, ":");

    Then you fetch the right most part of the return_string after the colon:

    $return_string_trim = substr($return_string, $colon_pos+1);
    

    Then you replace the commas with <br />:

    $return_string_html = str_replace(",", "<br />", $return_string_trim);
    

    And then you return the string:

    return $return_string_html;
    

    At least, I think ….

    #55931

    Anonymous
    Inactive

    So this is kind of similar to a question I’ve already asked. But now I’m struggling with the styling of the echo.

    To echo the checked boxes I use the following code:

    function locaties_search() {
        global $searchandfilter;
        $sf_current_query = $searchandfilter->get(3403)->current_query();
        return $sf_current_query->get_fields_html(array("_sft_locatie"), array('show_all_if_empty' => false));
    }
    
    add_shortcode('locatiesearch', 'locaties_search');

    And then I use the following shortcode to echo the results:
    <?php echo do_shortcode('[locatiesearch]'); ?>

    Right now it’s displaying the results like:
    Location:Location-x, Location-y

    What I would like is to have it just echo like so:
    Location-x
    Location-y

    What code should I use?

    #52078

    In reply to: Getting value from url


    Trevor
    Participant

    This?

    <?php
       //Get a multiple fields values by passing an array of field names
       //replace 1526 with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(15)->current_query();
    	print_r($sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false)));
    ?>
    #52076

    In reply to: Getting value from url


    Trevor
    Participant

    I see the error. My bad for copying and pasting. The forum has changed the quotes 🙁

    <?php
       //Get a multiple fields values by passing an array of field names
       //replace 1526 with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(15)->current_query();
    	print_r $sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false));
    ?>

    Or, I hope that is it.

    #52072

    In reply to: Getting value from url


    Anonymous
    Inactive

    If I use this code:

    <?php
       //Get a multiple fields values by passing an array of field names
       //replace 1526 with the ID of your search form
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(15)->current_query();
    	print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
    ?>

    It “breaks” the page…?

    #52071

    In reply to: Getting value from url


    Trevor
    Participant

    I need to see the array structure to know which element to grab. This code instead of the current echo should give the array:

    print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
    
Viewing 10 results - 141 through 150 (of 188 total)