Try this:
while ( $query->have_posts() ) : $query->the_post();
if ( has_tag('tag-slug') )
{
get_template_part( 'content', 'tag-slug' );
}
else
{
get_template_part( 'content' );
}
endwhile;
You would then need to create content.php
and content-tag-slug.php
with the appropriate content.
You could also look into setting up Post Formats. A bit more work up front, but a nicer experience down the road.
Related Posts:
- How can I send an email using PHP?
- Should I use spl_autoload_register() in my plugin?
- List of all theme customizer control types?
- Shortcode putting html such as
- Load post content into iframe
- Editor role cannot save custom theme options
- Installing wp3.2.1 on IIS; getting empty sessions
- WordPress widget in custom theme
- Specific Loop For 2 Within Each
- POSTS list in WordPress by views
- How do I enable HTML5 prefetching on this page?
- Anything I can add to functions.php to make text widgets accept PHP?
- What’s the proper way to use wp_enqueue_script/style?
- How to find the output of contact form 7 shortcode? [closed]
- Print number of post (in reverse)
- Is it necessary to upgrade to php7? [closed]
- Can’t increase posts_per_page by variable
- Use WordPress’s Media Uploader/ Manager in non WordPress php application
- How to check If Oembed is empty or not
- How do I access the media settings
- How can I output a php value into a JS file within WordPress?
- Set post title based on first h2 element in the content section
- Custom field value not saving when it contains a URL?
- WordPress to end support for PHP 4?
- Why does WordPress remove my variables in the URL?
- How do I let users upload files to a chosen location?
- get current custom post ID by WP_Query method
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Wp-login appears White Screen, Error: Cannot modify header information
- Show css depending on activity type in BuddyPress activity-loop [closed]
- Mute Debug Messages from Plugins
- Reprinting tags with all attributes
- Set WP_query ‘order’ option by another tables value
- Settings API callback function inserts html quotes from nowhere
- Show when user is online/offline in real time on user_profile.php
- can i fetch a custom metabox data in another page or post type?
- Call to undefined function get_userdata() in plugin
- How to add different text in each result of foreach?
- how to update and display an option without reloading the page
- ‘Post-thumbnails’ feature does not seem to register
- multiple where condition in result query
- Featured or last post with a different WordPress style without plugin
- Writing PHP code in pages without issue?
- How to get User Time Zone in WordPress?
- Fix error Gravatar alt
- Code snippet to show current php version inside “At a Glance” box in admin
- WordPress yoast seo plugin – parse snippet var in meta description
- Different SMTP based on domain
- How to Update an old theme for the latest wordpress version
- How to replace the default domain on wp get shortlink
- show recent posts php code error?
- How to edit the styles for the table of pages/post listed in the admin when you click on pages/posts?
- How can I use custom menus with a Bootstrap WordPress theme?
- How to track who has deleted files
- how to show images without passing it to timthumb.php file for resizing
- Show Featured Image Dimensions and size frontend with shortcode
- How to remove/hide collapse menu for user/subscriber?
- How to redirect outgoing links via my own website
- How to implement __() function in my theme’s php file?
- remove values within an array user meta
- In PHP how do I make my navigation bar show certain links to admins only?
- How to get post titles by post ID and integrate with my code?
- how to get data from two different table from wordpress database
- Display a custom name when the user has no name settle in his account
- Why can’t I connect to the wordpress install page with Nginx?
- How does Permalink work with the AMP plugin after Removing Parent Permalink Catalog from Posts
- Discount in the specific product title using keyword ( Woocoommerce )
- WordPress: Redirect Main Site to Subsite in Multisite Where user is NOT logged in
- WordPress generates weird permalinks
- WordPress search query, how to modify the sql
- Make a full-width wordpress page
- Modify post image in full size
- Exclude category and post from loop in custom category.php
- Menu to the right of screen on desktop using Bootstrap 4
- Update an additional user meta field with a string
- Exclude a category slug on pagination
- number of posts with “Load More”
- Display specific main Sub Nav on Woocommerce product pages
- Putting hyperlinked and non-hyperlinked text in one line, centered, on .php [closed]
- Need Quick Help With Product Category Page
- how to remove replicating a tag inside loop?
- Perfmon performance counters on WAMP
- Page 2+ of taxonomy archives does not recognise sort-order from dropdown
- Not logged in when using http
- Editing a WordPress plugin to add my own functionality
- Retrieve first image url from custom post with pagination
- ajax form function error
- Simple Probléme in wordpress
- Advanced Custom Fields Show PHP in Text Areas
- New to WordPress & Freelancing [closed]
- Add a “Next Post” & “Previous Post” styled button manually to a post
- How to store the_post_thumbnail() value in a variable
- Query posts by custom taxonomy slug in WP REST API?
- oneOf JSON Schema validation not properly working for custom post meta value?
- How to disable page create for custom post type, but allow a page with the post types slug to be created?
- WooCommerce Modal Fly cart on add to cart – With AJAX
- /page/2/ redirect to 404
- How can I trim /page/ URL with PHP in WordPress
- Adding date and time to the same request