Forums Forums Search Search Results for 'get_field'

Viewing 8 results - 181 through 188 (of 188 total)
  • Author
    Search Results
  • #26581

    Ross
    Keymaster

    Hi Nina

    I noticed a PHP error in the active query class so I’ve just emailed you a fix.

    Once you get that, you can pass an array of arguments to the function, which controls the delims between the fields, please see:

    $args = array(
    	"field_delim" => "",
    	"delim" => ", ",
    	"show_all_if_empty" => true
    );
    
    echo $sf_current_query->get_fields_html(
    	array( "_sft_leadership", "_sft_management", "_sft_governance", "_sft_crosscutting" )
    	$args			
    );

    Hope that helps!

    – a word of warning, there is still some functionality to add to this class, and as this is the first version, I already think that the syntax for accessing the methods of this class might change – be sure to keep an eye on the changelogs in the next couple of updates.

    Thanks


    Anonymous
    Inactive

    Hello Ross,

    when I select multiple checkboxes in my form the URL string has terms separated by comma(%2C)
    http://leadernetnina.wpengine.com/resources/?_sft_leadership=culture%2Cemotional-intelligence%2Cleading-change

    when I output the search variables on the page using your guidance:

    <?php
    echo $sf_current_query->get_fields_html(
    array( “_sft_leadership”, “_sft_management”, “_sft_governance”, “_sft_crosscutting” )
    );

    ?>

    I get this result: Leadership: CultureEmotional IntelligenceLeading Change
    How do I turn output for user into: Culture, Emotional Intelligence, Leading Change ?

    Thank you so much for your help!
    – Nina

    #15339

    Ross
    Keymaster

    Hey there

    Good catch! In my dev version I’ve just added a couple of classes which should make hiding this much easier.. Update the code in includes\class-search-filter-register-widget.php.

    Replace the function form (line 75) with this one:

    	function form( $instance )
    	{
    		
    		
    		if (( isset( $instance[ 'title' ]) ) && ( isset( $instance[ 'formid' ]) ))
    		{
    			$title = __(esc_attr($instance['title']), $this->plugin_slug);
    			$formid = esc_attr($instance[ 'formid' ]);
    		}
    		else
    		{
    			$title = __( '', $this->plugin_slug);
    			$formid = __( '', $this->plugin_slug);
    		}
    		
    		?>
    		<div class="sf-widget-content">
    			<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p>
    			<p>
    				<label for="<?php echo $this->get_field_id( 'formid' ); ?>">Choose a Search Form: 
    					<select class="widefat" name="<?php echo $this->get_field_name( 'formid' ); ?>" id="<?php echo $this->get_field_id( 'formid' ); ?>">
    						<option value="0"><?php _e('Please choose'); ?></option>
    						<?php //
    							$custom_posts = new WP_Query('post_type=search-filter-widget&post_status=publish&posts_per_page=-1');
    							
    							if ( function_exists('icl_object_id') )
    							{
    								$formid = icl_object_id($formid, 'search-filter-widget', true, ICL_LANGUAGE_CODE);
    							}
    							
    							//var_dump($custom_posts);
    							while ($custom_posts->have_posts()) : $custom_posts->the_post();
    						?>
    							<option value="<?php the_ID(); ?>" <?php if($formid==get_the_ID()){ echo ' selected="selected"'; } ?>><?php the_title(); ?></option>
    						<?php endwhile; ?>
    
    					</select>
    				</label>
    			</p>
    			<p class="sf-widget-text-last">
    				<?php _e('Don\'t see a Search Form you want to use? <a href="'.admin_url( 'post-new.php?post_type=search-filter-widget' ).'">Create a new Search Form</a>.'); ?>
    				
    			</p>
    		</div>
    		<?php
    	}

    Now you should have no worries about upgrading the plugin ๐Ÿ™‚

    Thanks!

    #15035

    Anonymous
    Inactive

    Yes!
    get_fields() and get_field_object() does grab all custom fields info
    http://www.advancedcustomfields.com/resources/get_fields/

    #14966

    Anonymous
    Inactive

    Hi Ross,
    Thank you, you showed me the light ๐Ÿ˜‰
    Here is my approach (I am using the Advanced Custom Fields plugin for meta values):

    
    <?php 
              $copy = array();
              $is_search = false;
      	  $search_query = $wp_query->query;
    
              // META
              if($search_query['_sfm_location']){
                $field = get_field_object('location', false, array('load_value' => false));
                foreach ($field['choices'] as $key => $value) {
                  if($key == $search_query['_sfm_location']){
                    $copy[] = $value;
                  }
                }
                $is_search = true;
              } 
    
              // TAXONOMY
              if($search_query['_sft_project_category']){
                $term = get_term_by('slug', $search_query['_sft_project_category'], 'project_category');
                $copy[] = $term->name;
                $is_search = true;
              }
      ?>
    
    <?php if($is_search): ?>
      <p>Searching filters for: <?php echo implode(', ', $copy); ?></p>
    <?php else: ?>
      <p>A simple copy when if no search.</p>
    <?php endif; ?>
    
    #13234

    In reply to: Complex template query


    Anonymous
    Inactive

    Thanks for the reply Ross……I think the problem is that previously (before using the SP plugin or making any attempt to filter the results), I used the get_posts style of query in order to compare one of the meta keys holding a (expiration) date to the current date, and to not display results for those posts where the meta-value date had passed…..then I used a foreach loop and setup_postdata to access all the meta data. That query worked perfectly – returned results unless the date had passed. All was great until I was asked to add some live filtering of the results.

    And I did figure out (rather easily) how to use the meta data to setup the same comparison in the “advanced” setting in the SP plugin, so the SP query does weed out those posts whose meta date has passed, so all was good there – I did get the expected posts returned. The only thing was that the “results.php” file that displays the results has a custom query variable ($query->the_post) most likely using wp_query rather than get_posts, and that does not seem to work with setup_postdata – because as near as I can tell, setup_postdata only seems to work with ‘foreach’, not ‘while’ loops….and foreach seems only to work with get_posts.

    As mentioned, I’m not a coder, so there’s likely a better way to do what I’m trying to do, but it took me many, many days of research and testing to get my (old) query just right, it just wasn’t further filterable without your plugin.

    NOW I do have everything working just great, but using the ACF “get_field” and “the_field” instead of get_post_meta – formatting dates is working great too…..so really I’m a pretty happy camper today…..I just wish I was more skilled with programming, I might have found a cleaner way….

    But I really do love this plugin…..it’s very impressive. I’m off to give the free version (which I tested first) a great review on the repository and give a shout-out to the paid version, which is even better. I always do that when I find a worthy plugin. ๐Ÿ™‚

    #8261

    Anonymous
    Inactive

    Hi again,

    No, I’m not using a custom query inside mu search.php

    My file looks like this:

    <?php
    /**
     * @package WordPress
     */
    
    get_header(); ?>
    <?php
    	$total_results = $wp_query->found_posts;
    ?>
    
    <section class="content search-results">
    	<div class="wrapper">
    
    			<?php if ( have_posts() ) : ?>
    
    			<h2><?php echo $total_results ?> Search results for:</h2>
    		<div class="query"><?php the_search_query(); ?></div>
    
    		<div class="sort-results desktop">
    			Sort results by:
    			<div class="sort-links">
    				<a href="#">Relevance</a> | <a href="#">Popularity</a> | <a href="#">Name</a> | <a href="#">Date</a>
    			</div>
    		</div>
    
    		<div class="refine-search">
    			Too many results?
    
    			<button class="refine" onclick="refineToggle();">Refine your search</button>
    
    		</div>
    		<div class="refine-options" id="refine-options">
    
    			<div class="refine-container">
    				<h2>Filter results:</h2>	
    				<?php
    					echo do_shortcode('[searchandfilter id="44"]');
    				?>
    
    				<script>
    			
    				    $('input[type="checkbox"]').after('<span></span>');
    					
    					
    				</script>
    				
    			</div>
    			
    
    			
    		</div>
    
    		<div class="sort-results smartphone">
    			Sort results by:
    			<div class="sort-links">
    				<a href="#">Relevance</a> | <a href="#">Popularity</a> | <a href="#">Name</a> | <a href="#">Date</a>
    			</div>
    		</div>
    
    		<div class="result-list">
    
    			
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    			<?php 
    					$related_video_url = get_field('wistia_url');
    					$related_video_id = end((explode('/', $related_video_url)));
    				?>
    
    			<div class="result-item">
    				<div class="video-thumb">
    
    					<span class="likes">
    						<?php $post_like_count = get_post_meta( $post->ID, "_post_like_count", true ); // post like count
    									if($post_like_count != '0'){
    									echo $post_like_count;
    									}
    								?>
    						<svg x="0px" y="0px"
    		 viewBox="0 0 15 14.4" enable-background="new 0 0 15 14.4" xml:space="preserve">
    	<path id="favorite-3-icon_4_" fill="#ffffff" d="M7.5,14.4C2,9,0.4,7,0.1,5c-0.4-2.5,1.4-5,4.3-5c1.2,0,2.4,0.5,3.1,1.3
    		C8.3,0.5,9.4,0,10.6,0c2.9,0,4.7,2.5,4.3,5C14.6,7,13.2,8.9,7.5,14.4z M4.4,1.5C3.2,1.5,2.2,2,1.8,3c-1.2,2.5,1.5,5.1,5.7,9.3
    		c4.2-4.2,7-6.8,5.7-9.3c-0.5-1-1.5-1.6-2.6-1.6c-1.9,0-2.7,1.5-3.1,2.2C7.1,3,6.4,1.5,4.4,1.5z"/>
    	</svg>
    					</span>
    
    					<div class="image-thumb" id="wistia_thumbnail_<? echo $related_video_id ?>">
    					<div class="tag-overlay">
    						<strong>Tags:</strong><br>
    							<?php
    							echo get_the_tag_list('',', ','');
    						?>
    					</div>
    					<a class="thumb-play-overlay" href="<?php the_permalink(); ?>"></a>
    						
    					</div>
    					<div class="video-thumb-title">
    						<?php the_title(); ?>
    					</div>
    
    					<script>
    						getVideoThumbnail ('<?php echo $related_video_id ?>');
    					</script>
    
    				</div>
    				<div class="video-description">
    					<h4>Description:</h4>
    					<?php the_title(); ?>
    
    				</div>
    			</div>
    
    				<?php endwhile; else : ?>
    					<p><?php _e( 'Sorry, no pages matched your criteria.' ); ?></p>
    				<?php endif; ?>
    
    		</div>
    	</div>
    </section>		
    		
    <?php
    get_footer();
    ?>

    and my settings are like this: (screenshot)

    Settings screenshot

    Any ideas?

    #7471

    Anonymous
    Inactive
    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2014 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
     * 
     * 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() )
    {
    $query->the_post();
    $myid = get_the_ID();
    	?>
    	
    	<div class="row">
    	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    	<div class="filter-results" >
    	<?php echo $query->found_posts; ?> Ergebnisse  Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?>
    	
    	<div style="float:right;">
    	<?php sf_pagination_prev_next($query->query['paged'], $query->max_num_pages); ?>
    	<?php sf_pagination_numbers($query->query['paged'], $query->max_num_pages, " "); ?>
    
    	</div>
    	</div>
    	</div>
        </div>
        <div class="row">
    
        <?php
        
       
       if ($myid == '3100') {
        echo '<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">';
       
       dynamic_sidebar( 'wein' );
        echo '</div>';
      }
     
    
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		$post_type = get_post_type( get_the_ID() );
    	
    		?>
    
    	
    		
    		
    			
    			
    			
    				<?php 
    
    				switch ($post_type) {
    				    
    				    case 'wein': 
                            
                            echo '<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">';
    						echo '<div class="item-'.$post_type.'">'; 
    				    	$wine_id = get_the_ID();
    				    	$term_list = wp_get_post_terms($wine_id, 'winzer', array("fields" => "names"));
    						$title = get_the_title();
    				        $permalink = get_permalink();
    				        $name =  get_field('wine-name');
    				        $img_url =  get_field('wine-detail-image');
    
    				        if (empty($img_url)) {
    				        $img_url = 'http://www.weinamlimit.com/wordpress/wp-content/uploads/wine_empty.png';
    				       }
    				        $year =  get_field('wine-detail-year');
    				        $sf =  get_field('wine-detail-soul-faktor');
    				        $size =  get_field('wine-detail-size');
    				        echo '<div class="item-overlay"><div class="overlay-content">'.$sf.'<br>Flasche'.$size.'</div></div>';
    				        echo '<a href="'.$permalink.'" title="'.$title.'">';
    				        //echo '<img src="'.aq_resize( $img_url, '300').'" alt="'.$title.'"></a></div>';
    				        echo '<img src="'.aq_resize( $img_url, '300').'" ></a></div>';
    				        echo '<div class="wine-description"><h2><a href="'.$permalink.'" title="'.$title.'">'.$year.' '.$name.'</a></h2>';
    				        echo '<h3>'.$term_list[0].'</h3></div>';
    				        break;
    				    case 'winzer':
    				    	$grower_id = get_the_ID();
    				    	$term_list_country = wp_get_post_terms($grower_id, 'land', array("fields" => "names"));
    				    	$term_list_region = wp_get_post_terms($grower_id, 'anbaugebiet', array("fields" => "names"));
    				        $img_url =  get_field('winegrower-preview-image');
    				        $logo_url =  get_field('winegrower-logo');
    				        $title = get_the_title();
    				        $permalink = get_permalink();
    				        echo '<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">';
    						echo '<div class="item-'.$post_type.'">'; 
    						if (!empty($logo_url)){
    						echo '<div class="logo-overlay"><img src="'.$logo_url.'"></div>';}
    						echo '<a href="'.$permalink.'" title="'.$title.'">';
    				        //echo '<img src="'.aq_resize( $img_url, '600', '290' , true).'" alt="'.$title.'"></a></div>';
    				        echo '<img src="'.aq_resize( $img_url, '600', '290' , true).'" ></a></div>';
    				        echo '<div class="grower-description"><h2><a href="'.$permalink.'" title="'.$title.'">'.$year.' '.$title.'</a></h2>';
    				        echo '<h3>'.$term_list_region[0].', '.$term_list_country[0].'</h3></div>';
    				       
    				        break;
    				    
    				}
    
    		
    
    				
    
    				 ?>
    				
    			
    	
    			</div>
    
    		
    		<?php
    	}
    	?>
    
    </div>
    	<div class="row">
    	<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    	<div class="filter-results" >
    	<?php echo $query->found_posts; ?> Ergebnisse  Seite <?php echo $query->query['paged']; ?> von <?php echo $query->max_num_pages; ?>
    	
    	<div style="float:right;">
    	<?php sf_pagination_prev_next($query->query['paged'], $query->max_num_pages); ?>
    	<?php sf_pagination_numbers($query->query['paged'], $query->max_num_pages, " "); ?>
    
    	</div>
    	</div>
    	</div>
        </div>
    	
    	<?php
    }
    else
    {
    	echo "No Results Found";
    }
    ?>
    

    This is my results item, should be right?

Viewing 8 results - 181 through 188 (of 188 total)