I solved my problem by automatically adding the tag ‘light’ to all my projects. And then query all the post and projects with the light tag like this:
Query post by taxonomy tag ‘light’:
$args = array(
'post_type' => array( 'projects' , 'post' ),
'tax_query' => array(
'relation' => 'OR',
array(
'taxonomy' => 'post_tag',
'field' => 'name',
'terms' => 'light'
)
),
'post_status' => 'publish'
);
query_posts( $args );
Add tag ‘light’ to all projects on publish:
add_action('publish_projects', 'projects_post_type_tagging', 10, 2);
function projects_post_type_tagging($post_id, $post){
wp_set_post_terms( $post_id, 'light', 'post_tag', true );
}
It’s not the most elegant solution but it works. If theres a better way to solve this problem i’ve would like to know.
Related Posts:
- What does this PHP function code mean? [closed]
- Restrict custom post type to only site administrator role
- How do I append multiple taxonomies to the URL?
- Linking Two Post Types
- How to force one column layout on custom post type edit page?
- Creating “static” taxonomies to choose from, inside custom post type?
- modify all posts of a category to “no comments allowed”
- Why is the »_builtin« parameter not advised in »register_post_type()« for custom post types?
- Showing current taxonomy terms
- Custom Post Type with Custom Title
- automatically create taxonomy with same name as post title
- Rewrite custom post & taxonomy to share same URL path
- Assigning a role to a specific custom post type (and ignoring other post types)
- Display posts in random post types
- Custom Post Type by user
- saving custom post type data to different table in wordpress
- Query post types with multiple keys
- [Plugin: Posts 2 Posts] Changing display order of connections
- same archive template for different custom post
- Display taxonomy term only if there’s a value
- Get all posts WHERE custom_field is LIKE value
- Get the post children count of a post
- How to delete all posts from a custom post type?
- Check Title Unique Or Not and If not error message and dont save
- Remove All, Published and Trashed Post Views in Custom Post Type
- How to post twitter like updates on wordpress
- Show Two custom Post type and their posts on category page
- apply filters only to specific post listing without check the url parameters
- Custom post type and body_class: Remove “blog” class
- Deleting Custom Post type data using mySQL command
- How to get the post type from a category id?
- Is there a way to have the view link on manage posts page to open in a new window or tab?
- Display only one post each WEEK
- How do I do this with WordPress? Taxonomies?
- List custom taxonomy specific to one custom post type
- Meta query for custom post type ignored in main query
- Get related posts of child term of custom post type
- Show titles, date of all posts on single category page
- Several post types on WP Query by tag and taxonomy
- Update postmeta Parent when post_status child change
- Allow users to create posts without logging in?
- How to sort posts in a custom post type by title in ascending order by default?
- Redirect to another page using contact form 7? [closed]
- Variable not working in WP_Query
- Get_the_terms restrict output
- Custom post type menu
- YOAST SEO won’t work on custom post type archive [closed]
- Separate Content from gallery (custom post type)
- WordPress Count posts within a custom post type
- Copy/Move selected taxonomy terms to another taxonomy for posts
- Custom post type tags not showing in search
- Problems making shortcode with custom post types and taxonomy
- Query Multiple Custom Post Types & Exclude a Taxonomy Term
- Building a Data Intensive Website with WordPress
- How set template for “custom post type” individual post
- Question about link two types of data in wordpress
- Why is my custom post content only viewable when signed into WordPress?
- wp_set_object_terms creates taxonomies but does not add custom posts to it
- How can i display a taxonomy? i have created a plugin and then a custom type. and a taxonomy , also i have register it
- Define multiple prefixes for custom post type
- Set a Default CPT taxonomy by taxonomy id
- Adding specific custom fields (images) to post excerpt
- Convert attribute woocommerce terms (taxonomy terms) in posts of custom post type
- How to manage a dynamic multi-level page hierearchy system?
- Limit posts per page depending on the size of a div?
- Delete Post by User
- Multiple Custom Post Type with different Taxonomies
- creating a custom post template
- Filter By Term Not Working – Custom Post Type
- Problem to get the link of the default ‘post’ post type like the orther custom types
- One Post with different content, depending on a Page
- Custom Post Type
- Custom Post Type used for FAQs Accordion
- Sort by Custom Post Type (Multiple Loop)
- Display all post types together
- Turn post into simple slideshow
- How to make a template for a specific post of a custom post type?
- How to delete unnecessary custom post types in the UI
- show only one category posts in admin
- How to create a job post by email parsing? [closed]
- show posts under custom post type with same autj
- How to automate the creation of advanced layout article/post
- display posts, pages and custom post types from another wordpress site
- is therer any wordpress function to retrieve a specific html element from post content
- How to develop Knowledge center in WordPress Website
- Custom Taxonomy’s Label to change the text appearing in Appearance > Menu
- Slug for standard post post_type
- How to add post_type=value when editing that post type in the WordPress admin?
- Taxonomy custom post type URL
- How do I display the taxonomy for a custom post type in an array
- Multiple tag cloud filtering
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Filter second dropdown (tax) based on first dropdown (cpt)
- list posts of two post types in a single template
- Add a form in every post and save data in post meta
- Correct way adding External classes to Custom Post type and output their methods to template
- Rest Api not working with Iframe in form data
- Show all post of a taxonomy with one specific term not working
- Post type cloud like tag cloud?