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
- Displaying Custom Posts on a Page
- Shortcode not working with post counter
- Problem: wp_query outputs all images on site
- How do I require the specification of term in a custom post type and custom taxonomy?
- Custom Post, set object Taxonomy terms in plugin
- How to include term custom meta into the custom taxonomy term permalink structure
- Setup template_redirect using has_term when NO term assigned
- Get custom post type’s fields in a while loop as variables
- Get terms that contain posts that in turn belong to other terms?
- Custom Post Type within the Loop on Homepage (Page Template)
- How to get custom posts sub category link
- Custom while loop for hierarchical display of a taxonomy
- The loop seems stuck to a single (now deleted) post
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Posts per row on archive page (custom post type)
- How do I know the ‘meta_key’ for ordering my custom post type
- Display latest x posts from all categories in Custom Post Type/Taxonomy
- Display taxonomy terms, child terms and posts in a template
- Foreach inside shortcode not working as planned
- Use custom walker to add taxonomy terms to main nav menu
- Custom Theme With Custom Loops
- Custom Post Types strange pagination problem
- Conditional statement for if archive page has posts which contain certain taxonomies/categories/tags, show those terms
- Add term to custom post type on draft
- PHP Code to Display Term URL & Name of a Post Under a Custom Post Type
- Displaying custom-taxonomy-terms sorted by parent/child-hierarchy?
- Custom post type conditional in loop
- Display related custom taxonomy posts in sidebar
- pagination not working for category.php (custom post types in categories)
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- How do I control the output of a custom post type in the loop?
- Display custom post type posts first, then default posts
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Three Most Recent Posts, One Per Term
- Does WP have a global of $id?
- How to get WordPress term attached to the Post?
- Query posts with double taxonomy
- Output terms for custom post types
- WordPress Loop if/else
- get_the_title() is returning results from previous loop
- Custom Post Loop pulling all custom posts, not just one
- Conditional for a Single Post That Belongs to a Category?
- Wrapping x posts in html without leaving empty html
- WP Query post__in not returning correct results
- Custom Post Type single.php template only shows the latest post
- Sort posts in loop by the WooCommerce Membership of the author
- return only the first two terms of custom post
- Print current post category during WP_Query
- Adding predefined terms to a taxonomy
- Including all post id’s of a custom post type into an array
- How to add terms (without deleting others)
- How to include custom post type posts on a page?
- 4 column-loop ordered alphabetically with entries grouped (and labeled) by their first letter
- Tag page only display 10 posts
- Get parent category id from child category page for custom taxonomy
- How can I group posts by months and years?
- Pagination Error : Duplicate argument being outputted
- get_post_type is always post
- Multiple Custom Post Type queries, how to DRY it up
- Custon Content within WordPress Loop
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Bootstrap accordion looping through posts incorrectly
- Main query not querying any posts in custom taxonomy template
- Loop increase number
- Custom post type showing same Post on all Pages
- get_post_meta is not working inside shortcode
- Using wp_query to modify the loop in index.php for a CPT
- Category archive in with conjunction with custom post type is empty
- the_post() is printing titles in page footer
- Add arguments to get_the_terms for custom post types
- How to get only child terms from a custom taxonomy of current post type?
- Custom WP_Query doesn’t display all posts
- Custom query – get_the_terms not work
- Query & the_content() is showing in the header
- Create Array from custom post type to display a slider
- Move Genesis Single Page/Single Post Title
- get parent content inside child posts
- 3 random images from custom post type, each in a div with a diffrent class
- Two column layout with alphabetical ordering
- How to Display Posts From Category Within a Custom Taxonomy?
- Post loop count is not in order
- Control content before and after custom post type loop
- Custom Post Types Archives and Single Pages not showing custom taxonomy data
- Listing custom post types on archive page with array
- get_pagination not working on a custom post type query (using WP_Query)
- How to Make infinite loop of post
- WP_Query with custom post type ID
- Shared terms between taxonomies
- Displaying multiple post types on home page
- looping though custom post types and only return results in a given taxonomy
- Get_the_terms restrict output