• Resolved pfm

    (@pfm)


    Dear Jacob,

    I’m cleaning up my site and right now I’m on the /tag/ pages. They (right now) only show all my articles regarding the TAGs. What I want to do is the following:

    On each tag-page (i.e. https://fosm.de/tag/port-ellen/) show all articles AND pictures with this tag.

    I found the Shortcode for Filtering on tags in your docu. It would read like this for me:

    [wppa type="slide" album="#tags,tag1" size="auto" align="center"][/wppa]

    Where tag1 is the Tag regarding the actual tag-Page.

    If I enter this code into the description it is not working. You mentioned that this has to sit in the LOOP. The description is used in the HEADER in my theme.

    Can I adjust my tag.php to do the following:

    CASE #ofpictures
    = 0 => do not show anything
    = 1 => show only one picture (not the slideshow)
    >1 => slide

    Best would be to have this at the end of all articles shown (but first page if pagination).
    i.e.: https://fosm.de/tag/port-ellen/
    Pictures should show up before the closing Text “FoSM – Friends of Single Malt – ist ein deutschsprachiger Blog rund um Single Malt Whisky….”

    Doing it in the tag.php would mean to have a generic solution.

    Thank you for your advise.

    Best regards
    Peter

    BTW: using wppa+ 5-4-24-001
    https://www.ads-software.com/plugins/wp-photo-album-plus/

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

    (@opajaap)

    Shortcodes can be placed on a page. They will work. Do not bother about being inside the loop. On a page is inside the loop.

    [wppa type="slide" album="#tags,tag1" size="auto" align="center"][/wppa]

    looks correctly and should work.

    Note that the tags must be literally correct. Your example is about tag Port Ellen, but the tagged photos have tag Portellen.

    Since a few months you can have photo tags with spaces, so either change the photo tags to Port Ellen, or enter in the shortcode: album="#tags,Portellen"

    Thread Starter pfm

    (@pfm)

    Dear Jacob,

    thank you for the quick reply.

    I will have to adjust and add a lot of my tags. This will be one of the next todos.

    The tag-pages are somehow special as far as I know. In the tag.php there is text included which you can add in WP-Admin (Beitr?ge->Schlagw?rter in german; posts->tags in english?). Each of these can be called by a link like the above using the slug. Above the example for port-ellen.

    So there is no page where I could add the shortcode or did I miss something?

    But I could add some code to the tag.php if wppa supports this kind of function. Is this possible? And is it possible to get a number of pictures (regarding the filter)?

    My idea is to change once the tag.php and automatically every picture tagged with the same slug will show up automatically.

    Is this possible?

    Thank you.

    Best regards
    Peter

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    I see.

    You can bulk edit tags in Photo Albums -> Settings admin page Table VIII-13. This will save a lot of work.

    It is possible what you want.
    You can call wppa directly from a php file ( tags.php in your case ).
    You can supply some data in the function args, and this and more in global data.

    Basically it works as follows:

    if ( function_exists( 'wppa_albums' ) ) { // wppa is active
    echo wppa_albums();
    }

    The following arguments exist:

    wppa_albums( $id = '', $type = '', $size = '', $align = '' );

    But, you can supply everything in the global var $wppa.

    All elements of $wppa with their defaults are:

    $wppa['src'] 			= false;
    	$wppa['searchstring'] 		= '';
    	$wppa['topten_count'] 		= '0';
    	$wppa['is_topten'] 		= false;
    	$wppa['lasten_count'] 		= '0';
    	$wppa['is_lasten'] 		= false;
    	$wppa['comten_count'] 		= '0';
    	$wppa['is_comten']		= false;
    	$wppa['is_featen']		= false;
    	$wppa['featen_count'] 		= '0';
    	$wppa['is_tag']			= false;
    	$wppa['is_single'] 		= false;
    	$wppa['is_mphoto'] 		= '0';
    	$wppa['single_photo'] 		= '';
    	$wppa['start_album'] 		= '';
    	$wppa['is_cover'] 		= '0';
    	$wppa['is_slide'] 		= '0';
    	$wppa['is_slideonly'] 		= '0';
    	$wppa['is_slideonlyf'] 		= '0';
    	$wppa['film_on'] 		= '0';
    	$wppa['is_landing'] 		= '0';
    	$wppa['start_photo'] 		= '0';
    	$wppa['photos_only']		= false;
    	$wppa['albums_only'] 		= false;
    	$wppa['page'] 			= '';
    	$wppa['is_upload'] 		= false;
    	$wppa['last_albums']		= false;
    	$wppa['last_albums_parent']	= '0';
    	$wppa['is_multitagbox'] 	= false;
    	$wppa['is_tagcloudbox'] 	= false;
    	$wppa['taglist'] 		= '';
    	$wppa['tagcols']		= '2';
    	$wppa['is_related']		= false;
    	$wppa['related_count']		= '0';
    	$wppa['is_owner']		= '';
    	$wppa['is_upldr'] 		= '';
    	$wppa['is_cat'] 		= false;
    	$wppa['bestof'] 		= false;
    	$wppa['is_subsearch'] 		= false;
    	$wppa['is_rootsearch']  	= false;
    	$wppa['is_superviewbox'] 	= false;
    	$wppa['is_searchbox'] 		= false;
    	$wppa['may_sub'] 		= false;
    	$wppa['may_root'] 		= false;
    	$wppa['portrait_only'] 		= false;

    I think you only have to supply:

    $wppa['start_album']
    $wppa['is_slide']

    If the size and align are not the defaults as defined in the Settings page, you can optionally add:

    $wppa['fullsize'] = '500'; // for 500 px or:
    $wppa['auto_colwidth'] = true; // for responsive

    The ( almost ) complete code becomes ( for responsive ):

    if ( function_exisis( 'wppa_albums' ) ) {
    	$my_tag = 'Port ellen'; // example, replace 'Port ellen' by your var that contains the tag.
    	$wppa['start_album'] = '#tags,'.$my_tag;
    	$wppa['is_slide'] = '1';
    	$wppa['align'] = 'left'; // or 'center' or 'right'
    	$wppa['fullsize'] = '0.8'; // for 80% of the available width
    	$wppa['auto_colwidth'] = true; // for responsive
    	echo wppa_albums();
    }

    This should do it…

    For more detailed info see wppa-functions.php

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    I forgot to mention that the code should start with:

    global $wppa;

    Thread Starter pfm

    (@pfm)

    Dear Jacob,

    thank you! Great – it works!

    You can see a working example here: https://fosm.de/tag/ardmore/

    I did the following to get this result:

    <?php if ( function_exists( 'wppa_albums' ) ) :
    			$my_tag = single_tag_title( '', false );  // var that contains the tag.
    			global $wppa;
    			$wppa['start_album'] = '#tags,'.$my_tag;
    			$wppa['is_slide'] = '1';
    			$wppa['align'] = 'center'; // or 'left' or 'right'
    			$wppa['fullsize'] = '1.0'; // 0.8 for 80% of the available width
    			$wppa['auto_colwidth'] = true; // for responsive
    			echo wppa_albums();
    		?>
    		<?php endif; ?>

    There is only one little thing left to have it perfect: is it possible to get the number of images back? Then I would be able to decide like mentioned above how to display it.

    Right now, if there is NO fitting tag ($my_tag) then it shows a little box “no pictures found”.

    Best regards
    Peter

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Try this, it should work and is more future safe and maintainable, and even simpler:

    <?php if ( function_exists( 'wppa_albums' ) ) {
    
    	// Init
    	global $wppa;
    	global $thumbs;
    
    	// Find the tag
    	$my_tag = wppa_sanitize_tags( single_tag_title( '', false ) );
    
    	// 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 do_shortcode( '[wppa type="slide" album="#tags,'.$my_tag.' size="1.0" align="center"][/wppa]' );
    	}
    
    	// If no photos, say it and clean up !
    	else {
    		echo 'Es gibt leider keine photos mit schlagwort <b>'.$my_tag.'</b>';
    		wppa_reset_occurrance();
    	}
    } ?>

    Thread Starter pfm

    (@pfm)

    Dear Jacob,

    that great! Works perfect. Thank you once more!

    Best regards
    Peter

    Thread Starter pfm

    (@pfm)

    Close Ticket.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Use wppa shortcode/functions in PHP | tag.php’ is closed to new replies.