You can make use of get_post_type( $post )
to check whether a post belongs to a certain post type
Inside your loop, you can do the following check
while ($my_query->have_posts()) : $my_query->the_post();
if ( 'activists' == get_post_type() ) {
/* Custom code for 'activists' post type. */
} else {
/* Custom code for the other post types. */
}
endwhile; wp_reset_query();
Related Posts:
- Display Custom Taxonomy Alphabetically
- Listing all term items alphabetically / sorting loop
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Excluded Custom Taxonomy Term Posts Displaying in loop
- posts_per_page is not working by term
- Display title of all custom posts from same taxonomy term on a custom post template
- Add active class to foundation 6 tabs while looping categories
- How to show terms used only for particular custom post type. Filter creation perpose
- How do you get the count of posts in an archive page?
- Display current taxonomy term when inside custom post type
- Get term slug of current post
- How to show Y number of custom posts after every X normal posts?
- How do I list custom taxonomy terms without the links?
- wp_insert_term doesn’t work with custom post type’s taxonomy
- Archive page…limiting posts per page
- Adding custom post type to loop
- display multiple term post from taxonomy in a single page
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Taxonomy posts on Archive page
- How to show related posts by category or custom post type?
- Posts navigation in custom post type single.php not working
- Display custom field of specific post where post title matches variable
- How to output wordpress custom tags separated by comma?
- Remove duplicated values from a loop
- How to connect two custom post types with nested loops
- Normal pages as children of my Custom Post Type
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Custom Post Type Loop throws 500 error when used in widget
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Group CPT posts by custom taxonomy
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Problem: wp_query outputs all images on site
- The loop seems stuck to a single (now deleted) post
- Foreach inside shortcode not working as planned
- Custom Post Types strange pagination problem
- Display related custom taxonomy posts in sidebar
- Does WP have a global of $id?
- Output terms for custom post types
- How to add terms (without deleting others)
- Bootstrap accordion looping through posts incorrectly
- the_post() is printing titles in page footer
- Two column layout with alphabetical ordering
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- Dynamically insert code to custom post type loop
- Get terms of a post but only if they’re also the child of a specific term
- Search Filter CPT, Custom Loop
- Pull in taxonomy field of custom post type in new query
- How to add a lightbox to class mix?
- How to display custom taxonomy term meta on custom post type
- Get post content from another section in custom single page
- Posts are not rendering perfectly [closed]
- Default post_tag for custom post type
- does wp_insert_term link the term to a certain post ID?
- Query all post types but limit to parents
- Grab all Custom Posts by multiple taxonomies and terms
- Looping through custom taxonomy and display custom post types (Custom Post Type UI)
- Custom post class, generate unique id from 1 to x depending on amount of posts?
- Create a custom taxonomy template that loops through child categories in term order?
- Why is the output of a call to the_excerpt different when the call seems to be identical?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Only looping through pages that have children or subpages
- creating a foreign key like relationship with custom post types
- On click some element i want to use some template
- How to Enable Ascending or Descending In WordPress Default Built-in Loop
- Fetch data from two custom post types and create multidimensional array for output to html table
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?
- Order posts by taxonomy terms
- Loop all post on single.php
- How to display custom taxonomy term specific post?
- How to associate custom taxonomy terms with custom post type?
- get_queried_object not work in taxonomy page
- Accessing download link from the loop with WP Download Manager Pro
- Custom WordPress theme not displaying posts from category
- get_the_terms child terms for current post/custom post only
- Combine multiple separate lists into one
- Prev / Next Post Same taxonomy Custom Post Type
- Pages of my taxonomy terms are showing all posts
- custom post type single page
- How to get all posts related to a taxonomy?
- How to prevent post to repeat on my loop?
- Custom post types not displaying per category
- How to show Y number of custom posts after every X normal posts?
- Custom Post Status & Taxonomies
- Create an additional template page for every term taxonomy
- Taxonomy Grid Archive Help?
- Load different template for CPT (in loop) in my plugin?
- How to loop custom post type posts by author?
- List a custom post type’s posts ordered by nested custom taxonomy
- Inserting random posts
- How to add a post counter to the list of custom taxonomy terms?
- Author template – separate custom post type by custom taxonomy term for $curauth
- Custom Loop and Standard Blog Loop Issue
- Custom loop won’t work, can’t find problem
- Categories and page filtering with pre_get_posts
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Loop to pull content from parent element in custom post type [duplicate]
- How to manage a bookstore
- How to create custom page templates with default page layout framework?