$args = array(
'type' => 'post',
'orderby' => 'name'
);
$tags = get_tags($args);
foreach($tags as $tag) {
$the_query = new WP_Query( 'tag='.$tag->name );
if ( $the_query->have_posts() ) {
$the_query->the_post();
$desired_posts[] = get_the_ID(); // all the post IDs stored here.
} else {
// no posts found
}
wp_reset_postdata();
}
$args1 = array(
'post_type' => 'post',
'orderby' => 'date',
'post__in' => $desired_posts,
'posts_per_page' => -1
);
$the_query = new WP_Query( $args1 );
echo '<ul>';
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>'. get_the_title() . '</li>';
}
} else {
// no posts found
}
echo '</ul>';
Related Posts:
- Get excerpt using get_the_excerpt outside a loop
- Retrieve each widget separately from a sidebar
- how to upload image using wp_handle_upload
- Avoiding using a loop to access a single post
- Adding ‘current_post_item’ class to current post in the loop
- WordPress Alphabetical Glossary close div in loop
- Where should I use post_class()?
- Landing Page – Redirect Loop?
- How to make multiple Column in archive Page?
- Sort Popular Posts by Views for the Last Week
- category__not_in — anyway to use category name instead of id?
- Filtering posts by multiple taxonomies
- Is it possible to display previous post revision?
- Fix inefficient loop breaks post.php on form submit
- Help with Changing loop.php?
- Adding shortcode closing tag after a loop
- Get Pagination (WP-PageNavi) not to work
- Filtering The Loop For Single Page and Blog Page
- the_content() seems to block my ACF-code
- Pulling current post/page data into header.php
- Removing the_content() from the page
- Loop and Page template : my WP_query don’t take args
- Category Ajax call
- Change front-page layout after x amount of posts ( while in the same loop)
- How can i use the same template file with a widget and category loop?
- WordPress Loop inside Loop?
- Filter the loop by categories using checkbox form
- Loop in Related Posts WordPress
- Conditional query that displays on Woo product attribute pages
- Custom post type appearing within the previous one on archive.php
- How do I go about looping through a advanced custom field on a particular page inside of another page
- Template structure
- How to inject posts from certain category on home page
- The Loop – mixed ASC and DESC order
- Filter the_posts doesn’t work on search page
- Showing sticky posts with get_posts()
- single.php – how to mark current page in the loop
- How to order by multiple fields using standard query_posts?
- Get 1 more post in loop
- Pagination not working in category listing [duplicate]
- How to get the excerpt for is_home() outside of the loop isn’t working
- Category links including all posts
- Custom loop ordering not working
- First archive page with a few posts
- Hiding a row in the loop if empty
- Loop through ACF taxonomies and output associated posts
- How to get user ID’s from multiple usernames?
- Pagination on custom post type on front-page.php
- get_template_part() Not Working in Loop
- get_delete_post_link() inside Loop stubbornly returns nothing
- Query posts only with actual text content (not including shortcode or images)
- Problem with Front-Page.php loading recent posts
- Comments_template doesn’t work
- Get markup for post without loading into the template
- How can this multiple loop have pagination as described?
- Default featured image set as background image [closed]
- Breaking up the results of a loop
- How to synchronize The Loop with the max post per page?
- How to add a byline to all the pages?
- How do i create a list-posts-page?
- Exclude posts based on an array
- Displaying member join date on page
- Ascending order has strange effects on wordpress loop
- Is file_exists() compatible with timthumb.php? [closed]
- get post images to link to external sources
- Using is_page_template inside loop
- Set depth of pages to fetch
- Trying to get all links in my posts
- Creating a User-Adjustable chart in WordPress
- Archive: Lists itself
- How to show the last article in a different way in my blog?
- Reorder posts in a loop: have the posts by one particular author below the others
- How to execute a user loop with shortcode
- how to get author comment inside the loop?
- How to create loop in custom page, and get id from url into this loop?
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Custom loop not working in singular.php, working in other pages
- Loop Posts Outside of WordPress Installation
- Strange problem with wp_get_attachment_image_src database (db) query count
- How to include posts from one category, into a separate category of posts?
- how do i make this loop work
- Archive sorted by month – separate
- Making a specific page wordpress compatable that is not index
- Display single post inside accordion based on form submission results
- One page loop issue with posts
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Building theme so user can change header image [closed]
- Get query result before posts are displayed?
- WordPress Group By Problem
- display only parent replies count in index.php
- using the loop on a page
- Tag custom loop show posts
- While loop inside another while loop
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- Fix html inside a for loop [closed]
- Display all posts in a page code for template
- Insert multiple custom components after x-number of posts
- Hide old posts each year