Forums Forums Search Search Results for 'the_field'

Viewing 10 results - 41 through 50 (of 64 total)
  • Author
    Search Results
  • #180876

    Anonymous
    Inactive

    Hi there,

    When i got the custom fields (ACF) to display on a previous project i did not need to use get_post_meta i thought that was what your plugin does! all i used was <?php the_field(fieldname); ?>

    I am already returning some of the post data eg: <?php the_title(); ?> – i just need to get more of the data from the post in the search results. your reply doesn’t really clarify my issue.

    Any further suggestions?

    #175770

    Trevor
    Participant

    I see an error in the archive-workshops.php template file. Line 49 is </ul> but it needs moving up to line 45 (inside the IF and WHILE).

    In the archive-workshops.php template file I can see on line 15 a shortcode from our free version. Can this be removed?

    When I edit the find-din-workshop page, I also see the same shortcode in a text element. Again, can this be removed?

    Will this page be where the search and results are?

    If so, can we try a different method? See here the guide to use the Shortcode Results method:

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/using-a-shortcode/

    And make sure to follow the guidance for Customising. In the custom result.php file, find this part (lines 47-72):

    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<div>
    			<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    			
    			<p><br /><?php the_excerpt(); ?></p>
    			<?php 
    				if ( has_post_thumbnail() ) {
    					echo '<p>';
    					the_post_thumbnail("small");
    					echo '</p>';
    				}
    			?>
    			<p><?php the_category(); ?></p>
    			<p><?php the_tags(); ?></p>
    			<p><small><?php the_date(); ?></small></p>
    			
    		</div>
    		
    		<hr />
    		<?php
    	}
    	?>

    and replace it with this:

    	<ul>
    	<?php
    	while ($query->have_posts())
    	{
    		$query->the_post();
    		
    		?>
    		<li>
                    <a class="workshop-thumbnail" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
    
                    <p class="workshop-emnefelt"><?php the_field('Emne'); ?></p>
    
                    <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
    
                    <h5 class="workshop-pris"><?php the_field('pris'); ?></h5>
    			
    		</li>
    		
    		<?php
    	}
    	?>
            </ul>
    #152948

    Anonymous
    Inactive

    Hello

    Currently, when I create a custom post type search locally my query works but once I have ported it over to my server it doesn’t, and I can’t seem to find out why? I have tried multiple variations of this that I have found online.

    Here is my Code-

    <?php
    $args = array
    (‘post_type’ => ‘Reports’,
    ‘search_filter_id’ => 5647
    );
    $query = new WP_Query( $args );
    if( $query->have_posts() ) : while( $query->have_posts()) : $query->the_post(); ?>
    <div class=”result “>
    ” class=”result”>
    <div class=”reports-links”>
    <div class=”report-grid1-3″>
    <div class=”report-title”>
    <p>report number</p>
    <h4><?php echo the_field(‘report_number’); ?></h4>
    </div>
    </div>
    <div class=”report-grid2-3″>
    <div class=”report-title”>
    <p>Date of issue</p>
    <h4><?php the_field(‘report_date’); ?></h4>
    </div>
    </div>
    </div>
    <!– #post-## –>
    </div>
    <?php endwhile; ?>
    <?php else : ?>
    <div class=”no-posts “>
    <h3 class=”text-center”>
    <?php _e( ‘Something went wrong, please search the exact report number.’ ); ?>
    </h3>
    </div>
    <?php endif; wp_reset_postdata(); ?>

    the site is currently live at https://www.icagemlab.com

    The search input that relates to this code is in the header to the right of the logo “report verification”

    Thank you for your time in advance

    Rob

    #119857

    Anonymous
    Inactive

    The custom content is added in a custom field in the back-end and then called in results.php, before the loop as follows:

    <?php if( get_field('luxury_holidays_content') ): ?>
    
    	<div class="masonry-layout-panel custom-content">
    			
    		<?php the_field('luxury_holidays_content'); ?>
    		
    	</div>
    	
    <?php endif; ?>

    Strangely, if I hard code the custom content in results.php, it is always visible. However, if I call it in PHP as above, it gets removed when a search or form reset is performed.

    #102011

    Anonymous
    Inactive

    Great stuff, how come you are echoeing get_field instead of using the_field?

    The example you provided outputs single fields fine, but what would be some example code to use ACF’s Post Object?

    Using the example ACF site supplies doesnt work as expected.

    #101977

    Anonymous
    Inactive

    Sorry for the badly formatted code, cant see where to edit my post. Here it is formatted a little more readable:

    <?php
    while ($query->have_posts())
    {
    $query->the_post();
    
    ?>
    <tr>
    <td>
    <?php
    
    $post_object = get_field('customer');
    
    if( $post_object ): 
    
    // override $post
    $post = $post_object;
    setup_postdata( $post ); 
    
    ?>
    <?php the_title(); ?>
    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>
    
    </td>
    <td><?php the_date(); ?></td>
    <td><?php echo the_ID(); ?></td>
    <td><?php echo the_field('reg_no'); ?></td>
    </tr>
    <?php
    }
    ?>
    #94498

    Trevor
    Participant

    Yes, this is possible. The snippet that inserts the thumbnail in your code is this:

    <?php 
      if ( has_post_thumbnail() ) {
        echo '<span class="responsive">';
        the_post_thumbnail("small");
        echo '</span>';
      }
    ?>

    (Note that many people change the ‘small’ to ‘thumb’ to load and even smaller image)

    To output this as an image linked to the post, the code would be this:

    <?php
      if ( has_post_thumbnail() ) { ?>
        <span class="responsive"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail("small");?></a></span>
      <?php	} ?>

    I am not sure about your use of span to add the responsive bit. In my theme (bootstrap based) it adds img-responsive this way:

    <?php the_post_thumbnail("small", array( 'class' => 'img-responsive' ));?>
    

    In your case, I do not know what your field is, but your code to output that field needs to replace <?php the_permalink(); ?> in this. Maybe like this <?php the_field('artistpage'); ?>

    #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)

    #63425

    In reply to: ACF and CPT output


    Anonymous
    Inactive

    I got my results themed by altering the plugins/search-filter-pro/templates/results.php file, but this is not ideal. I have created mythemename/search-filter-pro/templates/results.php and mythemename/search-filter/templates/results.php but neither of these is being loaded.
    If you have a url where any of this is explained, it would be appreciated.
    In the meantime, I did get a custom field, named location, wrapped by adding this to results.php in the plugin folder:
    <div class="customtest"><?php the_field('location'); ?></div>

    #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

Viewing 10 results - 41 through 50 (of 64 total)