• Hi thank you for your job.
    Your plugin is very well thought out !

    I updated the plugin yesterday, and I have a problem with my template page.
    Before the update the fields of ACF, get_the_excerpt() and the_post_thumbnail_url( ‘thumbnail’ ) displayed well
    since the update this is no longer displayed.

    Can you help me please ?

    This my code :

    <?php
    /**
     * This template will be provided with the variable $a_z_query which is an A_Z_Listing instance.
     * You can override this template by copying this file into your theme directory.
     */
    
    ?>
    
    <?php if ( $a_z_query->have_letters() ) : ?>
    <div id="az-slider">
    	<div id="inner-slider">
    		<?php
    		while ( $a_z_query->have_letters() ) :
    			$a_z_query->the_letter();
    		?>
    			<?php if ( $a_z_query->have_items() ) : ?>
    				<div class="letter-section" id="<?php $a_z_query->the_letter_id(); ?>">
    					<h2>
    					<span><?php $a_z_query->the_letter_title(); ?></span>
    					</h2>
    					<div><ul>
    						<?php
    						
    						while ( $a_z_query->have_items() ) :
    								$a_z_query->the_item();
    					
    						?>
    					
    							<li>
    								
    								<div class="auteurs table_auteur">
    								<div class="row_auteur">
    									<div class="cell_auteur auteur_1">
    										<a href="<?php $a_z_query->the_permalink(); ?>" title="<?php $a_z_query->the_title(); ?>">
    											<?php if (has_post_thumbnail( $post->ID ) ){ ?>
    											<img src="<?php echo the_post_thumbnail_url( 'thumbnail' ); ?>" width="100%" alt="Photo de <?php $a_z_query->the_title(); ?>"/>
    											<?php }else{ ?>
    											<img src="<?php echo get_template_directory_uri()."/img/auteur.jpg" ?>" width="100%" alt="Photo de <?php $a_z_query->the_title(); ?>"/>
    											<?php } ?>
    											</a>
    								
    								
    									</div>
    								
    									<div class="cell_auteur auteur_2">
    										<h3><?php $a_z_query->the_title(); ?><span class="date">
    								<?php if(!empty(get_field('date_de_deces'))&&(!empty(get_field('date_de_naissance')))){?>
    								<?php echo "[".get_field('date_de_naissance')." - ".get_field('date_de_deces')."]"; ?>
    								<?php }
    								else{
    									if(!empty(get_field('date_de_naissance'))&&(empty(get_field('date_de_deces')))){
    										?>
    								<?php echo "[".get_field('date_de_naissance')." à aujourd'hui]"; ?>
    								<?php
    									}
    								}
    								?></span></h3>
    										<p>
    										<?php echo get_the_excerpt(); ?><br>
    										<a href="<?php $a_z_query->the_permalink(); ?>" title="<?php $a_z_query->the_title(); ?>">Lire la suite</a>
    									</p>
    								
    									
    								</div>
    								</div>
    								</div>
    								
    								
    								
    							</li>
    						<?php endwhile; ?>
    					</ul></div>
    					<div class="back-to-top"><a href="#letters">Retour en haut</a></div>
    				</div>
    			<?php endif; ?>
    		<?php endwhile; ?>
    	</div>
    </div>
    <?php else : ?>
    	<p><?php esc_html_e( 'There are no posts included in this index.', 'a-z-listing' ); ?></p>
    <?php
    endif;
Viewing 9 replies - 1 through 9 (of 9 total)
  • I have the same probleme.
    I try : $a_z_query->the_post_thumbnail();

    But it doesn’t work.

    Math.

    • This reply was modified 6 years, 2 months ago by mathskater.
    Plugin Author Dani Llewellyn

    (@diddledani)

    This is a side-effect of my attempting to save a bit of memory and generation time. I purposely don’t load the full post object, so the thumbnail isn’t in memory.

    Try with the following instead:

    <?php
    $post = $a_z_query->get_the_item_object( 'I understand the issues!' );
    if ( has_post_thumbnail( $post->ID ) ) :
        the_post_thumbnail( 'thumbnail' );
    endif;
    ?>

    The text I understand the issues! must be exactly that, to confirm that you do understand that on a large collection of posts you might hit slowness or memory usage problems.

    Sorry, but for me it does not work.

    Thread Starter pierreg11

    (@pierreg11)

    same problem

    Plugin Author Dani Llewellyn

    (@diddledani)

    What is the behaviour of the failure?

    e.g. Does the page show an error? Is the page completely loaded, or is the html cut-off? Is the listing complete, just missing the thumbnails? Do any thumbnails load or are they all missing?

    Could you try some debugging steps such as inserting an else clause on the has_thumbnail() check – the example below will print the post ID to make sure that the $post object is loaded properly:

    if ( has_thumbnail( $post->ID ) ) :
        ...
    else :
        echo "<br />The thumbnail cannot be found. The post ID is '{$post->ID}'.<br />";
    endif;

    Here is the error that appears :

    Fatal error: Uncaught Error: Call to undefined function has_thumbnail() in /app/public/wp-content/themes
    Stack trace:
    #0 /app/public/wp-content/plugins/a-z-listing/classes/class-a-z-listing.php(654): include()
    #1 /app/public/wp-content/plugins/a-z-listing/classes/class-a-z-listing.php(675): A_Z_Listing->do_template('/app/public/wp-...')
    #2 /app/public/wp-content/plugins/a-z-listing/classes/class-a-z-listing.php(690): A_Z_Listing->the_listing()
    #3 /app/public/wp-content/plugins/a-z-listing/functions/shortcode.php(203): A_Z_Listing->get_the_listing()
    #4 /app/public/wp-includes/shortcodes.php(319): a_z_shortcode_handler(Array, '', 'a-z-listing')
    #5 [internal function]: do_shortcode_tag(Array)
    #6 /app/public/wp-includes/shortcodes.php(197): preg_replace_callback('/\\[(\\[?)(a\\-z\\-...', 'do_shortcode_ta...', '[a-z-listing po...')
    #7 /app/public/wp-includes/class-wp-hook.php(286): do_shortcode('[a-z-listing po...')
    #8 /app/public/wp-includes/plugin.php(203): WP_Hook->apply_filters('[a-z-li in /app/public/wp-content/themes on line 51
    Plugin Author Dani Llewellyn

    (@diddledani)

    I mistyped, and you copied verbatim.

    Try replacing has_thumbnail with has_post_thumbnail to get past that specific undefined function error.

    Thank’s !
    But nothing is displayed, that’s the code I’m using, maybe it can help to understand where the problem is coming from.

    <ul class="columns max-<?php echo $column_limit; ?>-columns">
    <?php
    while ( $a_z_query->have_items() ) :
    $a_z_query->the_item();
    ?>
    <li>
    <a href="<?php $a_z_query->the_permalink(); ?>">
    <?php
    $post = $a_z_query->get_the_item_object( 'I understand the issues!' );										if ( has_post_thumbnail( $post->ID ) ) :										    the_post_thumbnail( 'featured-image-abecedaire' );										endif;
    ?>
    <div class="az-box-data">										<div class="glass"><i class="fal fa-search-plus"></i></div>									</div>
    <div class="az-title"><?php $a_z_query->the_title(); ?></div>
    </a>
    </li>
    <?php endwhile; ?>
    </ul>
    Plugin Author Dani Llewellyn

    (@diddledani)

    The code you shared in the previous post does not call the_post_thumbnail or get_the_post_thumbnail, nor does it check that there is a thumbnail with has_post_thumbnail. You still need to do those bits. They need to appear after this line:

    $post = $a_z_query->get_the_item_object( 'I understand the issues!' );
    
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘After update, the field ACF not appear in page’ is closed to new replies.