Search Results for 'get_field'

Forums › Forums › Search › Search Results for 'get_field'

Viewing 10 results – 151 through 160 (of 219 total)
  • Author
    Search Results
  • #95968

    Trevor
    Participant

    Do you mean echo $sf_current_query->get_field_string("_sft_category"); with a t and not an m?

    Does the guidance and examples in the documentation help?

    #95951

    Anonymous
    Inactive

    Hello,
    when I try to output currently selected filter values, this is working:

    echo $sf_current_query->get_field_string(“_sfm_category”);

    But this is not working, as well as any filter that start with _sfm:
    echo $sf_current_query->get_field_string(“_sfm_character”);

    What can be reason?

    #92230

    Anonymous
    Inactive

    Hi Trevor,

    In fact, i’ve a search.php file for my results. I wrote this code which appears on the top of the results :

    global $searchandfilter;
    global $post;
    	$author_id = $post->post_author;
    	$author = get_the_author_meta('display_name', $author_id);
    	$sf_current_query = $searchandfilter->get(802)->current_query();
    	$num_res = $wp_query->post_count;
    	echo $sf_current_query->get_field_string("_sft_category").'<br />';
    	echo $sf_current_query->get_field_string("_sft_thematique").'<br />';
            if($num_res == 0) {
    	echo 'Terme(s): '.$sf_current_query->get_search_term().'<br />';
    	}
    	echo 'El&eacute;ment(s) trouv&eacutes(s): ' .$wp_query->found_posts;

    I can display the author which is selected from the author select list but i don’t want to display anything if no author selected.

    I need a valid snippet which might be :

    if ($author_id != '0') {
    	echo $author.'<br />';
    	}

    Thank you for your help.

    Best regards.

    #91601

    Anonymous
    Inactive

    Hello Trevor,
    What i meant : You give some snippets to display some informations like thais :

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(802)->current_query();
    echo $sf_current_query->get_field_string("_sft_category").'<br />';
    echo $sf_current_query->get_field_string("_sft_thematique").'<br />';
    echo 'Terme(s): '.$sf_current_query->get_search_term().'<br />';
    echo 'El&eacute;ment(s) trouv&eacutes(s): ' .$wp_query->found_posts;

    I’d like to have a snippet to display the author chosen in my select list. If i try that code, it doesn’t work :

    echo $sf_current_query->get_field_string("authors");

    Is it possible to realize this ? It’s not in your documentation.

    Thank you for your help.

    Best regards.

    #89605

    Anonymous
    Inactive

    Hi

    sorry for english i’m french. I got a little problem with my custom post template page. I got “reference” custom post type, with ajax system who display content ref when clic on ref’s list.

    but if i filter results with plugin, my ajax doesn’t work anymore. how can i reload my ajax after display results ?

    you can test there : http://syntesia.smartinteractive.net/references/

    this is my ajax function :

    (function($) {
        $(document).ready(function() {
    
            //$( '.ref_item' ).click( function() {
    
            $("#gallery-content-center").on("click", ".ref_item", function() {
    
                var post_id = jQuery(this).attr('id');
    
                console.log('cliqué : '+post_id);
    
                jQuery.ajax({
                    url : display_ref.ajax_url,
                    type : 'post',
                    data : {
                        action : 'display_ref',
                        post_id : post_id
                    },
                    success : function( response ) {
                        //alert(response);
                        $('.fullnews').hide('fast');
                        $('.fullnews').html( response ).slideDown('fast');
                        $('.fullnews').show('fast');
                        var thumbH = $('.fullnews .left').height();
                        var arrow_top = (thumbH*1.08 - 175)/2;
                        var windowsH = $(window).height();
                        $('.fullnews .right').css('height',thumbH+'px');
                        $('.arrow-left, .arrow-right').css('top',arrow_top+'px');
                        $('.overlay').css('display','block');
                        $('#overlay'+post_id).css('display','none');
                        $('html, body').animate( { scrollTop: $('.fullnews').offset().top }, 1000 );
                        //console.log('thumbH : '+thumbH+' arrow_top : '+arrow_top+' windowsH : '+windowsH);
                        //console.log('réponse: '+response);
    
                    }
                });
    
            });
    
        });
    
    })( jQuery );

    and how i declare them in wordpress :

    wp_register_script( 'ajax_ref', get_template_directory_uri().'/js/ajax_ref.js', 'jquery', time(), true );
            wp_enqueue_script( 'ajax_ref' );
            wp_localize_script( 'ajax_ref', 'display_ref', array(
                'ajax_url' => admin_url( 'admin-ajax.php' )
            ));

    and the response :

    add_action( 'wp_ajax_nopriv_display_ref', 'display_ref' );
    add_action( 'wp_ajax_display_ref', 'display_ref' );
    
    function display_ref() {
        if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
            $post_id = $_POST['post_id'];
    
            global $post;
            setup_postdata( $post );
    
            $args = array(
                'post_type' => 'reference',
                'posts_per_page' => -1,
                'order'=>'ASC',
            );
            $posts = get_posts($args);
    
            foreach ($posts as $post) {
    
                if($post_id == $post->ID):
    
                    echo '<div class="col-md-1">';
                    echo '</div>';
                    echo '<div class="col-md-5 left">';
                    echo '<span class="title">' . get_the_title($post->ID) . '</span>';
                    echo '<div class="content">' . get_field('description', $post->ID) . '</div>';
                    echo '</div>';
                    echo '<div class="col-md-5 right" style="background: url(' . get_field('servingurl', $post->ID) . ') center center / cover;"></div>';
                    echo '<div class="col-md-1"></div>';
                    echo '<div class="clear"></div>';
    
                endif;
    
            }
    
            wp_reset_query();
        }
        die();
    }

    how can i load my ajax to work with filter please ?

    #87390

    Ross
    Keymaster

    Yup the form elements are there, but thats not the whole “field” as some fields contain multiple form elements (like ranges).

    Again, this is coming in v3, a class you can use to build your own fields.

    The problem with the current version of S&F is thats it poorly decoupled and got bloated.

    Its grown over 3 years, had 1 major refactor, and its due for another.

    You’ll have a very hard time to create your own fields on the fly, and its not something I can easily explain I’m afraid.

    All I can say is, look at the display-shortcode file, which outputs the html of the fields (the function is called get_field), that then relates to the others files you mentioned above (in the fields director), but you’ll have to figure out how so many other classes work, just because of poor decoupling.

    Thanks

    #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'); ?>
    
    #70909

    Anonymous
    Inactive

    function sf_filter_query_args( $query_args, $sfid ) {

    if($sfid==1225){

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1225)->current_query();

    $sf_current_query->get_field_string(“_sfm_event_archives”);
    $_sfm_event_archives_array = $sf_current_query->get_array();
    $archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value];

    //print_r($archive_is_check);

    if($archive_is_check != ‘1’){
    $args_custom = array(
    “meta_key” => “imic_event_start_dt”,
    “orderby” => “meta_value_num”,
    “order” => “ASC”,

    “meta_query” => Array (
    “event_archives” => Array (
    “key” => “event_archives”,
    “value” => “0”
    )
    )
    );

    $query_args = array_merge($query_args, $args_custom);
    }

    // si aucun filtre d’appliqué
    //if($sf_current_query->is_filtered()!=1){}

    }

    return $query_args;

    }
    add_filter( ‘sf_edit_query_args’, ‘sf_filter_query_args’, 100, 2 );

Viewing 10 results – 151 through 160 (of 219 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.