This does a query for all posts of type family guy, tosses them into the $fg_obj
then loops through each post, grabs its tags, and creates a flat array of just the tag name. Then that array gets put into a new array with the post ID. This seems like a strange way of getting this info (because I don’t know the final purpose of this array), but it should be the format you’ve requested.
$args = array( 'post_type' => 'family_guy', 'posts_per_page' => -1 );
$fg_obj = get_posts($args);
$posts_with_tags = array();
foreach($fg_obj as $fg) {
$tags = get_the_tags($fg->ID);
$tag_arr = array();
foreach($tags as $tag) $tag_arr[] = $tag->name;
$posts_with_tags[$fg->ID] = $tag_arr;
}
Related Posts:
- Load custom posts with same tag as page
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Custom Tag Description unable to display just below and outside of the Loop
- add custom tags for custom post type in wordpress
- Custom post tag images not displaying with ACF
- WordPress Custom Post Type and sort by Tags
- Query Custom Post Type by Tag
- Can custom taxonomies items have attached properties?
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- Get rewrite slug of custom post type in template
- Show Different Header on a Specific Post ID
- Get Post Primary Category
- Weird problem happening with custom taxonmy when creating/updating posts
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Admin notice not displaying
- Can’t get order_by meta_value_num to work properly
- Create custom post type on successful woocommerce order [closed]
- Adding custom tables to WordPress
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Change Permalink Structure for Tag.php template
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Does anyone have a plugin that could automatically tag custom post types in wordpress?
- Very Slow Page – How to Optimize # of Queries?
- Dynamic page outside WordPress
- Using wordpress template tags within an array
- Getting the URL of the parent page
- Custom query to filter posts that have current post as a taxonomy [closed]
- Custom post type permalink returns bad url
- Return the thumbnail meta data for getter and setter
- Can’t query tag and post_type at the same time
- How to display selected taxonomies by their parent
- Group posts by custom post type
- Custom Field Order by Last Name and First Name
- Pagination for custom php code
- get_posts of Custom Post Type AND Custom Taxonomy
- Tag page with Custom Post Types not returning any posts
- What’s the difference between same wp functions get_posts(); functions in different form?
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- Custom Post Type Loop throws 500 error when used in widget
- how to check if custom post type column already exists?
- Get posts from a custom post type by child categories of a parent category
- Received nothing after executing AJAX post function
- How to make sure content doesn’t display if selection is empty
- Custom Post-Type not in admin menu
- get the custom post type title/name
- Page vs Custom Post Types Differences/Issues
- If post has custom field then display css-class
- Push metadata in array
- How to customize a permalink (URL) structure?
- Troubles with saving metabox
- CPT + CMB2: data not displaying for only first post in loop
- How to make a field appear only if a post meta field has a defined value?
- Replace text in post from cvs
- Get parent categories of custom post type
- Custom post types and tag archive pages/permalink structure issue
- Tag Archive for Custom-Post-Type Posts yielding 404 when permalinks set to postname
- Can I list a custom post type within another custom post type in the admin area?
- Get custom post type list for every category shortcode
- How do i calculate the total of values of custom fields in custom post types?
- I would like to have different styles for my posts based on the content of each post
- search also in taxonomy, tags and custom fields
- Checking if Post Title is Unique as Loop Criteria
- Custom post type getting wrong categories and tags
- Listing tags from a custom post type
- Query & Order posts by custom fields
- Custom post type – get_day_link()
- Set URL link to featured image of custom post type
- wp_update_term_count_now doesn’t work with a custom post type?
- Add tag to a custom post type doesn’t change the total of custom post type in backend
- AJAX load more for different custom post type loops
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- I’d like to cycle through existing posts in a post type, showing one per day ordered by title, and starting over when the last is reached
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Changing wordpress publication date to ACF date and time picker date not working
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Use custom metabox to update automatically a post after a given date
- get_post_meta not working on publishing
- creat filter with wp_query
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag
- How do I add a custom screen for a custom post type to be called from custom post row action?
- ACF field key/value to show on taxonomy list
- WordPress custom post type permalink rewrite shows page not found
- Using custom field content as expression in IF statement [closed]
- Can one create multiple Custom Post Types with a for loop?
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- How to display custom WP menus?
- Categorize custom post type
- How to Create Columns with WordPress and CPTUI display page ?
- Custom post type editor with dynamic selects, one drop down populating a second second drop down not working
- WordPress custom post type split into pages
- How to add custom field to view-edit post type page
- Assign External Database Queries to Global Variables and Make Them Accessible
- Hide a widget inside a div on specific type of post
- How to import a custom MySQL DB table into a WordPress custom post type
- Static apple-app-site-association file with wordpress