The $post
variable inside your function does not point to anything. You are declaring global $wp_query
(which you are not actually using), but not global $post
.
Related Posts:
- How to use a custom post type archive as front page?
- Display featured image from one CPT within another CPT query
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Loop increase number
- Get current user id
- Using Wp_Query, Json to add Highcharts series data
- Foreach loop returning more than one item when querying taxonomy
- Custom Form / Search with Custom Post Type Data
- set object terms after some some time of published post – functions.php
- subtracting the current post form then whole loop, which is generating all CPT titles
- Modify shortcode to work with custom taxonomies and slugs
- Filter by custom taxonomy slug on a custom post type
- Custom Post type and Custom Field WP_Query
- wpdb custom post_type problem
- Pagination on category page with custom post types
- Display multiple custom post types and sort them chronological by one of their fields
- Insert HTML inside link in a walker
- Using DISTINCT in wp_query
- Using global $post; to get featured image for custom post via WP_Query
- Query custom post type in the loop
- right_now_content_table_end function not working?
- How to add pagination to wp_query [duplicate]
- WooCommerce product search titles only
- Related posts in all categories of current post (custom post types)
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Notice: Undefined index: suppress_filters
- Loop through Custom Post Type, and then show children within each iteration
- Why does querying on post_tags (which has been applied to custom post types) only return posts?
- Sorting multiple custom post types without a meta key/value pair by sort order
- Custom Taxonomy Permalinks Redirection
- Including Custom Meta with posts_where query
- Add custom column in custom post type edit page
- Very Slow Page – How to Optimize # of Queries?
- orderby in custom WP Query does not work
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Can I create a loop with multiple post types and specify different $args for each post type?
- How to show CPTs in term archive
- Query custom post type by category slug
- Combining sorted and random CPT
- How to add post_type=value when editing that post type in the WordPress admin?
- wp_insert_post generates endless posts
- Display CPT posts based on specific taxonomy
- Remove standard meta boxes from custom taxonomy
- Can’t query tag and post_type at the same time
- Setting proper query for multiple custom admin filters
- shortcode to show custom post types by category
- Unable to retrieve any posts of CPT in wp-admin
- What’s the difference between same wp functions get_posts(); functions in different form?
- WP_Query: include custom post type only with specific meta value
- Pagination on a custom post type loop
- I did group my search results by post type, but how can i give each of them its own order?
- Dequeue scripts and styles only for specific custom post type
- showing custom post types of a certain category only
- WP_Query orderby modified to include custom meta changes
- Function to display custom post type on front page makes menu items dissapear
- WordPress custom loop filter by meta_key and value with serialize data
- Returning a list of custom post types excluding those without a specific meta_value
- query private custom post type
- Display custom post type from dynamic custom field
- custom post type not showing in menu
- Query/list all terms and their custom post count
- Linking to the most recent post in a Custom Post Type
- How to make sure content doesn’t display if selection is empty
- Show category ID on custom post type
- Filtering WP_Query Dynamically on the Front-End
- Show one item per category of a custom post type
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Storing posts from query and accessing later via AJAX call
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How to customize a permalink (URL) structure?
- Archive for custom taxonomy lists all posts instead of current taxonomy
- Genesis filterable portfolio isotope [closed]
- Query custom post type with tags
- wp_query check if integer exists in custom field’s array
- Custom Post Type with Templates using Meta Boxes?
- convert custom query to wp_query
- Wrong request query on cpt and tax
- Previous/Next Link by Meta Value in CPT
- Can I list a custom post type within another custom post type in the admin area?
- Change custom post type slug from plugin options
- Show custom post type filtered by category
- Randomize Posts. Skip the first post in ascending order
- Creating a navigation menu of all posts of a custom post type and their children posts?
- Get custom taxonomies from multiple posts
- Pagination for Custom Taxonomy Page [duplicate]
- Filtering WP_Query
- Search / Filter posts on Title/Content OR Tags
- Pagination on with query_posts in custom post type template
- Wp_query: sort by PHP variable
- WP_Query most viewed posts, in multiple Post Types, last 30 days, excluding a specific taxonomy term
- Custom-Posttype & Custom Taxonomy WP_Query
- Crafting WP_Query array, sort by date
- Custom loop with multiple taxonomy queries
- Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
- Converting the_content string to an array?
- forming WP_Query for posts of all post types but from specific categories
- Get latest 3 posts from multiple CPT in one query
- Can’t edit custom post type
- Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”
- Display upcoming Events for next 7 Days