I do it with that but i don’t think this is so optimized!
function list_formation(){
$args = array(,
'post_type' => 'categories',
'posts_per_page' => 20,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
$formations = get_posts(array(
'post_type' => 'formations',
'post__in' => array(16061),
'meta_query' => array(
array(
'key' => 'categories', // name of custom field
'value' => '"' . get_the_ID() . '"',
'compare' => 'LIKE'
)
)
));
if($formations){
foreach ($formations as $categorie){
// $list = get_field('formations', $formation->ID);
// list of categorie with ID formation
echo the_title() . '</br>';
}
}
endwhile;
wp_reset_postdata();
}
Related Posts:
- Query all posts where a meta key does not exist
- Can I assign a template to a custom post type?
- How to remove “read more” link from custom post type excerpt
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Can you make a custom metabox field be required to save a new post?
- Best Way to Create a List of Musician Gigs in WordPress
- Custom Post Type Permalink For Parent/Child, 404 Page Not Found Error
- Filter a custom field based on selection of another custom field (ACF) [closed]
- Remove wpautop from all posts/pages except my custom post type
- Posts in Multiple Columns and Rows with one single loop
- Hide child term posts on parent term pages
- Custom field being erased after autosave
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Want to filter only parent post in admin area
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Post Via Email to a Custom Post Type
- how to only have one custom post type post?
- Remove current_page_parent from posts page link in WordPress nav menu
- How to display the categories of the post? (custom post type)
- Query to change custom post type with specific category
- CPT posts listed by category with custom rewrite URL, please help!
- Custom Post Type and Custom Taxonomy Permalinks
- allow edit of custom post type but not regular posts?
- Pagination problem
- How to add custom post type under option page
- register_taxonomy and register_post_type does not work [closed]
- Custom post type and body_class: Remove “blog” class
- How do I create a form to search a custom post type
- Custom Post type is being ignored in query
- Query var removed after rewrite
- Adding custom tables to WordPress
- Insert HTML inside link in a walker
- get_attached_media() on author page not working
- Custom Post Meta Data in Buddypres Activity Stream
- Getting posts under the custom post type ui category
- Add archive slug to default post post type
- map_meta_cap woes
- WordPress combined with a basic MYSQL table [closed]
- Set URL link to featured image of custom post type
- Automatically generate a delete post link and provide it to post creator
- Custom taxonomy and custom post type – wrong permalinks and template
- How to display custom WP menus?
- What to and how to proceed with CPT to make DB small and efficient?
- Storing a many to many post type relationship in post meta and keeping SQL ability for Joins
- Custom taxonomy returns 404
- Pagination with custom query, custom search form, single and pages, ajax and no plugins
- Unable to link categories to custom post type using standard function
- Cant get paginations on single.php to work with my custom post types
- Is it possible to show multiple (custom) post types at the wp homepage only by using pluging code?
- Programmatically change post visibility on save_post action return a 500
- How to select a template for a custom post type?
- Saving data for different custom posts
- Getting a custom post’s custom field based on another custom post’s custom field select
- Conditional tag only for front of custom post type
- wp_get_canonical_url showing first url of the post for custom page
- get the permalink never return with empty value
- Custom post type is using the index.php template
- Display 1 Post per taxonomy with polylang
- Blank search results on custom search
- Custom Posts and Posts – next_post_link and previous_post_link not working together
- using the loop in custom meta is messing up ‘add new’ post type
- Custom Post Type permalink doesn’t match post permalink
- Custom Post types and their corresponding theme files
- Cannot manage to display my CPT in Recent Posts widget
- Custom taxonomy terms hierarchical navigation
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- What is the best way to structure posts for the same event happening in different years?
- Apply a custom Template to a Custom Post Type from within a plugin
- How to create a Child & Siblings menu for a custom post type?
- Dynamically Adding Posts of Post Type to A List
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Automatic Set Category For A Custom Post Type
- Show parent category and subcategory once in while loop
- I cannot display custom posts in custom taxonomy
- How to build Custom Post Nav Menu inside of the Loop
- Allow duplicate permalinks slugs for custom posts by different authors
- How to check if a new private custom post type is created?
- Loading a stylesheet on a specific page [duplicate]
- Display related post content and custom field content
- Create an administation subpage containing posts in a certain category
- Custom 404 redirect for a luddite
- One-Time Script TimeOut for Large Data
- How can you use a page for a custom post type?
- Pagination functions won’t work
- Custom post type and google visibility
- How to create default taxonomy term for a custom post type? [duplicate]
- Extensive search filtering and results->PDF in the front-end
- title tag for custom post type remove taxonomy name from title tag
- Posts without featured image using other post’s featured image
- How to add a custom post type in child theme? (WordPress > 3.0)
- Displaying wp post categories into my custom metabox
- Display results from two Custom Post Types in page template
- Create a page selector using taxonomies
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Create page using same slug as custom post type
- Pagination not working
- Issues on saving data from CPT select metabox
- How can I get user URL by id
- selecting custom post types and taxonomies for hub page listing blocks