• Resolved pfm

    (@pfm)


    Hi,

    I did use some special code you provided me years ago. The idea is to list all picture thumbnails that fit to the TAG on the tag page.

    Today I recognized this no longer works (maybe due to updates):

    Fatal error: Uncaught Error: Call to undefined function wppa_get_thumbs() in ...
    
    I commented the line with the call of wppa_get_thumbs. This solves the issue but sure does not show any pictures. Is there a new function or another solution I can use?
    
    Thank you!
    
    The original code was:
    
    <code></code><?php if ( function_exists( 'wppa_albums' ) ) {
    
    				// Init
    				global $wppa;
    				global $thumbs;
    				global $photo_count;
    
    				// Find the tag
    				$my_tag = single_tag_title( '', false );
    				$my_tag = str_replace( '&', '&', $my_tag );
    				$my_tag = wppa_sanitize_tags( $my_tag );
    				// echo 'Debug:Tag='.$my_tag;
    
    				// Find the count of photos
    				$wppa['is_tag'] = $my_tag;
    				wppa_get_thumbs();
    				$photo_count = is_array( $thumbs ) ? count( $thumbs ) : 0;
    
    				// If photos, show them
    				if ( $photo_count ) {
    					echo '<h2 class="entry-title"><b>Galerie-Fotos</b> - passend zu dem Artikel-Schlagwort</h2>';
    					echo '</br>';
    		
    					//echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="auto" align="center"][/wppa]' );
    					echo wppa_insert_shortcode_output( do_shortcode( '[wppa type="thumbs" album="#tags,'.$my_tag.'" size="auto" align="center"][/wppa]' ) );
    				}
    
    				// If no photos, say it and clean up !
    				else {
    					//echo 'Es gibt leider keine passenden Fotos mit dem Schlagwort <b>'.$my_tag.'</b>';
    					wppa_reset_occurrance();
    				}
    				echo '</br>';
    			} ?><code></code>

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Jacob N. Breetvelt

    (@opajaap)

    wppa_get_thumbs() is now wppa_get_photos()
    Functionally the same

    Thread Starter pfm

    (@pfm)

    Dear Jacob,

    thank you. I replaced the function and now there is no error – but it does not show me the pictures… the calculation seems to return 0

    wppa_get_thumbs();
    				$photo_count = is_array( $thumbs ) ? count( $thumbs ) : 0;
    
    				// If photos, show them
    				if ( $photo_count ) {

    e.g. https://fosm.de/tag/talisker/

    Thread Starter pfm

    (@pfm)

    I replaced wppa_get_thumbs() with wppa_get_photos()

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    wppa_insert_shortcode_output() is obsolete, so change:

    //echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="auto" align="center"][/wppa]' );
    echo wppa_insert_shortcode_output( do_shortcode( '[wppa type="thumbs" album="#tags,'.$my_tag.'" size="auto" align="center"][/wppa]' ) );
    
    

    into:

    echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="auto" align="center"]' );
    
    

    ([/wppa] is also no longer needed but does no harm when it is there)

    I think it will work now, but keep also in mind that the rules whether a photo is visible for the current user is more strictly maintained, e.g. a photo with status ‘private’ will show up to loggedin visitors only etc.

    Thread Starter pfm

    (@pfm)

    I did change the line and check the pictures. The counter is still 0 and I do not get any pictures displayed.

    I checked:
    – the album has 18 pics
    – each pic is “published” (not private)
    – each pic has the tag “Talisker” (might this be a case sensitive issue? nothing changed on this side)
    – I removed the if clause and it returned “no pics found” in a box
    – I did insert the debug line
    echo 'Debug:Tag='.$my_tag;
    => Debug:Tag=,Talisker,
    so there seem to be added commas….

    Anything else I can do?

    Thank you!

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    The comma’s should not spoil it.

    Try this:

    // If photos, show them
    				if ( $photo_count ) {
    

    Change into

    // If photos, show them
    				if ( true ) {
    

    This will always print the <h2> tag, but then you can see if the shortcode works.

    If so, find the number of photos by this code:

    
    global $wpdb;
    $photo_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->wppa_photos WHERE tags LIKE '%$my_tag%'" );
    
    

    The comma’s are assumend to be in $my_tag. Tags are stored this way:
    ‘,Tag1,Tag2,Tag3,’

    This is to prevent finding ‘Tag1extra’ when searching for ‘Tag1’

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    AHA, got it after some testing!

    The result of wppa_get_photos is no longer stored in global $thumbs, so you have to find the count as follows if you want to stay using wppa_get_photos()

    $photos = wppa_get_photos();
    $photo_count = is_array( $photos ) ? count( $photos ) : '0';
    
    Thread Starter pfm

    (@pfm)

    First part solved. The counter returns me the correct/expected 19. It goes inside the loop to show the pics, but the WPPA shortcode seems not to work as it returns still the above message in the box saying (translated): no pictures found that fits search criteria.

    echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="auto" align="center"]' );

    the $my_tag:

    $my_tag = single_tag_title( '', false );
    $my_tag = str_replace( '&', '&', $my_tag );
    $my_tag = wppa_sanitize_tags( $my_tag );
    $wppa['is_tag'] = $my_tag;

    Any other mistake in the above you can see?

    Thank you!

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="auto" align="center"]' );
    
    

    contains an error, you miss a ”

    echo do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.'" size="auto" align="center"]' );
    
    
    Thread Starter pfm

    (@pfm)

    That’s it. Thank you!

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Thanx for your donation!

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘wppa_get_thumbs – undefined function’ is closed to new replies.