Multiple tags in URL
-
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_classThanks!
[please allow much more time to get a reply – http://codex.wordpress.org/Forum_Welcome#No_Bumping ]
The topic ‘Multiple tags in URL’ is closed to new replies.