The single_tag_title()
function returns the tag title while you need the tag slug or ID for use in query_posts()
. This should get you started:
if ( is_tag() ) {
$tag = get_queried_object();
$tag_title = $tag->name; // Same as single_tag_title()
$tag_slug = $tag->slug;
$tag_id = $tag->term_id;
}
http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters
Related Posts:
- Query Posts Incorrectly Displaying Tags Archives
- how to query posts by category and tag?
- Pagination on archive.php page
- How to create an attachments archive with working pagination?
- Problem with single-page for my custom post
- How do I make archives.php for one category only?
- How can i display the posts per week in a particular month?
- Make tag archive display post are ordered by post format
- Creating attachments archive in tags and categories
- Script that gets the first tag of post and query all other posts with the same tag
- Calling an Archive Page with specific Tag/Tax ID
- Different post slug based on archive
- No duplicate tags by category
- Query specific posts from parent by slug rather ID
- Query Posts Creates 404 Error
- How to go to tag archives using a form
- Create “archives by year and week” by category template
- posts_per_page no limit
- Alternative to query_posts for main loop? [duplicate]
- Query posts by custom taxonomy ID
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- Is it better practice to use query_posts, WP_Query, or get_posts to create various custom loops within a Page?
- WP 5.8 “Query Loop” block: where to place custom query?
- Best way to load page content in Fancybox popup?
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- Schedule Sticky Posts
- Total Count of Posts NOT in Selected Categories?
- Warning: urlencode() expects parameter 1 to be string, array given in and not getting the preffered output
- How to modify the query to exclude posts by slug?
- Return category slug / title from category ID
- Using database meta_values to calculate new post order using pre_get_posts or a ‘request’ hook
- exclude ids through post__not_in
- Tag system like Quora?
- post_status => publish not working
- Integrating post archive wtih another source and preserving date ordering
- How to fetch all posts in a category that were published between two given dates?
- get_meta_data within a loop
- how to exclude “featured” posts from the main loop?
- pass query string on url to filter media
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- Order posts by condition
- Co-authors plus problems with query_post
- Error sending array of inputs
- order posts by meta value on posts page
- Search breaks when querying main loop for category
- What is an equivalent of single_cat_title for getting the slug of the category?
- Adding conditional content to single post-type template
- Simple custom post query for all the posts or many of them not working
- Hook to return true when the_post() is used in a custom while loop
- Query posts by meta_key whose value is an array
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- using query_posts to pull posts out of a category in a while loop. Getting odd echo
- Echo a numerical value in query_posts
- Conditionals if tags exist?
- why to use query_posts() in custom page?
- Query posts to get all but the most recent post
- Always using the same ARRAY on different querys
- Currently using a query_posts() in my theme – want to use a request filter in stead
- Breadcrumbs stop working on a specific template file
- How do I add a tag slug to a category URL to filter posts?
- How to constrain the results to a specific post_type on tag archive page?
- Multiple posts/pages in one page?
- Order for custom field after the loop
- Custom post query error
- Multiple instances of query_posts
- Different layout based on post amount?
- If Query Post Returns 1 Post
- Calling Posts from Specified Cat
- Keeping get_posts’ offset and is_paged() synchronized
- odd behaviours from template tags
- How to get any type posts include attachments by ids?
- wordpress query_posts featured page always on top
- Create a Loop with Posts Ordered by Most Recent Comments
- Filter products on category AND tag
- Thousands of unwanted URLs/pages with “0” in slug created
- Tax query get first product with attribute value in pre_get_posts
- How do I stop the same post showing multiple times in a archive?
- Specifying image size used in template the_content
- allow user to edit posts made by others users based on the user role
- Taxinomy slug as var in parent archive page, without having a specific taxinomy page
- Change the Page Title of the Archive Page for Portfolio Tags
- Ordering Posts By Meta Data
- Custom Post Type tag taxonomy “Page Not Found”
- Weird slug in archives permalink
- Order posts by ACF checkbox
- Archive.php is not displaying tags
- Post per page not working
- Show previous month’s posts
- query_posts result differs from wp_query request result
- If meta_key has value = 6 | Change the wp_posts.post_date to current date
- Adding Category Argument into an Array for WordPress Query
- Collect posts from last 48 hours
- Run second query on page based on author of the first query
- Can you orderby slug in a taxonomy archive page using WP_Query?
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Why doesn’t this page query work?
- Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
- Sort posts with multiple meta_keys