I am not sure what your issue is precisely, you are not creating $post
, just accessing it. It is a very common sight in WordPress.
However from API point of view, is ID of current post is the only thing you need — use get_the_ID()
function to get just that, sans dealing with global yourself.
Related Posts:
- Taxonomy: Why ‘with_front’ => false DOES NOT WORK?
- Any way to make posts inherit properties/taxonomies through a single assigned taxonomy
- Ordering posts by custom taxonomy in admin area
- Custom post type taxonomies URL rewrite
- Linking between custom post types as if they where taxonomies?
- Glossary with Custom Post Type
- Best Way to Leverage Custom Post Type Related Content and Consider SEO
- Dynamically Create Terms in Taxonomy when Custom Post Type is Published. Almost There!
- Automatically assign a custom post to a custom taxonomy based on custom field value
- Remove taxonomy slug when not assigning taxonomy with custom post types
- How i add new link after Edit | Quick Edit | Trash | View in quick edit section
- pre get posts changing the query
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- How loop through posts based on custom fields
- Listing taxonomies from custom post type
- Custom Taxonomy Hierarchy for Custom Post Types (eg Categories and Subcategories)
- Querying CPT with Two Taxonomies
- Get Custom Field Values by Another Custom Field in WordPress
- Wp Rest API request posts from a custom taxonomy
- Output the content of a term organised by each of the CPT?
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Generate Shortcodes by Taxonomy
- How is this CPT code in functions.php adding a hidden “products” category?
- Is there a way to connect a custom post type to another custom post type’s taxonomy? (specific to locations)
- Displaying Multiple Post types in Taxonomy
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- I have 2 post types i need to show the post type contents in 2 select boxes [closed]
- Display Recently Added Custom Post Types with Custom Taxonomy Shortcode
- How do I display tags for a custom post type single page?
- wp_query check if integer exists in custom field’s array
- How can I set taxonomy programmatically
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- WordPress custom taxonomy, posts urls
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Dynamic dropdown select values depending on other custom field value
- Import data from CSV with custom taxomony empty
- Custom Post Type Loop with Query Var
- Full Custom Post Type List Organised by two Taxonomies
- URL rewriting for CTP assigned entity
- Query Custom Post Type Taxonomy term with multiple parameters
- How to group posts and get a mixed posts and groups view?
- Post format alternative?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Querying Custom Post Type, ordering by Custom Taxonomy Pagination Not Working
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Control content before and after custom post type loop
- post_type_link Filter – Too Few Arguments
- Rewrite custom post type with taxonomy
- Show categories of custom post type and not all posts
- how to count the current posts terms
- Reusable metabox backend and frontend
- Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]
- Archive page for custom post type and custom taxonomy
- Using page title as a link to term archive
- Add custom post type taxonomy tag to article class
- Custom Taxonomy dont save in a frontend form for post a custom post
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Creating custom post type and taxonomy archives and pretty URLs
- Should i use custom post type for a custom footer?
- best way to use custom taxonomy, post type and meta in a job system
- Show 10 newest post for each value of a custom taxonomy
- Display the link of a custom taxonomy
- Custom taxonomy: on the taxonomy term page show other taxonomy terms
- Get the taxonomy value in the post loop inside the archive page
- Error 404 change permalink term custom term taxonomy
- How to display custom post type taxonomy in Contact Form 7 text field
- Custom Post Type & Taxonomies – Rewrite
- Custom post categories are not displaying on the page
- get_posts wont produce a list of custom type from a given category [duplicate]
- CPT tags not showing when editing post
- PHP Warning with Custom Fields
- Don’t share custom taxonomy terms if applied to multiple Custom Post Types
- How to show custom post count in archive page
- Change CPT permalink to use the category
- How to add independent “Tags” to Custom Post Type?
- Display custom tax in “while” loop
- Show posts under a selected custom taxonomy term
- Linking Taxonomies
- Get posts under custom taxonomy and custom post type
- Flush rewrite rules when new cpt is registred
- Shortcode in excerpt
- How do I retrieve the title of a term of a custom post type with custom taxonomies?
- Show custom taxonomy not in submenu
- Custom Taxonomy is disabled on Edit page
- How to assign custom post template to its custom taxonomy terms
- Excluding top level from taxonomy and post loop
- tax_query showing no results
- Display posts from category in page
- taxonomy terms array not working
- How to display only taxonomies of custom post type in a page?
- Custom Loop for custom post type. Compare by meta_value?
- get tags from custom post type
- Permalinks Works for Custompost type but not with pages Why?
- How can I modify this blog loop to display custom post type posts?
- Highlight specific menu item when custom post is page
- Output assigned custom taxonomy to custom post type
- wp_dropdown_categories() searching is not working with CPT, please review my code
- Custom Field Search