• Hello,

    My blog currently is organized by tags and sometimes I will list post archives by tags. Often, two tags are used in the URL to list the posts with this tags.

    Example: http://www.myblog.com/tag/tag1+tag2

    I’ve downloaded the plugin Tag Sticky Post that will allow me to stick posts depending on which tag I’m currently browsing in my blog. The tag that will be checked is from the post’s custom_field “tag_sticky_post”. So, if I go inside the post and set post “A” to stick on tag “1”, if I go to http://www.myblog.com/tag/1 the post “A” will be shown on the top with a custom css class (to highlight it). So far so good.

    The problem is that the plugin can’t seem to work when I’m browsing archives for 2 tags at the same time, like the example I gave above:

    Example: http://www.myblog.com/tag/tag1+tag2

    The relevant code that will make this is pasted below (basically will add a custom css class to the posts that have a stick tag definied). Anyone knows how to change the code so it will work with 2 tags instead of just 1 tag in the url?

    /**
    	  * Adds a CSS class to make it easy to style the sticky post.
    	  *
    	  * @param	$classes	The array of classes being applied to the given post
    	  * @return				The updated array of classes for our posts
    	  */
    	 function set_tag_sticky_class( $classes ) {
    
    		 // Determine which tag archive we're on
    		 if( null != ( $tag = get_term_by( 'slug', get_query_var( 'tag' ), 'post_tag' ) ) ) {
    
    			 // If we're on an archive and the current category ID matches the category of the given post, add the class name
    			 if( is_archive() && 0 == get_query_var( 'paged' ) && $tag->term_id == get_post_meta( get_the_ID(), 'tag_sticky_post', true ) ) {
    				 $classes[] = 'tag-sticky';
    			 } // end if
    
    		 } // end if
    
    		 return $classes;
    
    	 } // end set_tag_sticky_class

    Thanks!

    [please allow much more time to get a reply – http://codex.wordpress.org/Forum_Welcome#No_Bumping ]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Heya,

    This is a unique use case that I’d not considered when building the plugin. This is something that I can implement and release in the next version.

    I’ll aim to have this taken care of by the end of the week!

    Just released an update for this. Should be available in your dashboard as soon as WordPress makes it available.

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

The topic ‘Multiple tags in URL’ is closed to new replies.