On a default install of WP you get always the ID of a post with the function get_the_ID()
. Id dosnt work this you go about the global var: $post
.
echo $GLOBALS['post']->ID
Is this not enough, then go about the global wp_query
$GLOBALS['wp_query']->post->ID;
Related Posts:
- How to override parent functions in child themes?
- Solution to render Shortcodes in Admin Editor
- How to run a function every 5 minutes?
- Define page template in wp_insert_post
- How to remove Customize from admin menu bar after WP 4.3
- Child theme functions.php do I use php open and close tags?
- Modify Admin Bar Link
- How to override admin-bar style
- why doesnt is_home() work in functions.php
- WP 4.4. responsive loads normal image after loading the responsive image
- Enabling shortcodes for custom fields
- Passing variables to templates (alternatives to globalizing variables)
- Load post with a different template?
- How can I tell if I’m on a login page? [duplicate]
- Get Category and Excerpt From wp_get_recent_posts
- Two different menus for two different locations?
- Error after editing functions.php
- How do I properly register bootstrap JavaScript into WordPress functions.php?
- Most efficient way to get custom database records from 20 buttons and 20 tables?
- Manipulate Output of wp_list_something: select menu instead of li’s
- how to fix Warning: Use of undefined constant _ – assumed ‘_’ (this will throw an Error in a future version of PHP)
- restore_current_blog required after switch_to_blog, if I use that in a function?
- ‘is’ functions and ‘get_query_var’ not working
- Empty Date Returned on my function
- Woocommerce Attributes pulling in wrong data
- How to get the post_name when in preview?
- “is_new_day()” alternative for years?
- How to hide a plugin metabox for non admins when a user adds a new post
- Getting Featured Image Caption to Only Show if Populated
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- How do I create page navigation linking to each H2 within the page? [closed]
- Echo tags used to describe the theme
- How to Display Frontend CSS for Administrator only
- How can I change a function in a parent theme via a child themes functions.php
- Automatically assign video ‘poster’ value to ‘filename’ for archive listing
- How can I make a widget shortcode to control all the widgets?
- admin-ajax.php + load-scripts.php hanging for minutes
- Unique sequential reservation code
- Where to add the permalink in this function?
- Show image exactly defined to a width
- wp-admin won’t load after setting wp-login custom url
- Always the Latest google jQuery instead of default WordPress jQuery
- Modify post filter to set custom number of posts per page and exclude child posts
- Remove “Published On” inside wp-admin
- Can’t call Javascript function – scope?
- Deprecated function get_user_by_email($email)
- Changing parent element’s class or style
- header_image() with CSS
- User function to return multiple get_post_meta()
- Why does get_template_directory_uri() not include “www”, only for enqueued stylesheets?
- Getting commenter meta
- How can i unload effect.min.js file?
- How can I pass a shortcode value to the head in wordpress functions.php
- Native gallery custom html output
- WordPress wraps span tags into p tags
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- why is this function firing on all child menu items as well?
- Custom styles in Tiny MCE with an external CSS file
- I changed Functions.php and now I get “cannot decode raw data NSURLErrorDomain:-1015” (not blank)
- How to add schema markup to WordPress menu function
- Use add_action within template
- two search forms on the same page
- contact form in template with jquery,validate and ajax
- Changing the header image using WPML
- current_page_item is missing inside wp_nav_menu
- Change default upload images size for contributors
- file.php not loaded?
- How to setup a popup registeration page in wordpress with function.php
- How to require a config file in a template and in function.php?
- How to add if statement on WordPress shortcode output
- Header menu aligned right on all pages except for single-post page [closed]
- Why does modifying the “read more” link remove the link class?
- How Do I Unhook This Parent Theme Function?
- Woocommerce product price change
- How to create an array if ’empty’?
- How to display different blocks for mobile and desktops
- get_field() with ID in one signal filter not working
- i can’t use wordpress functions in ajax loaded php file
- Woocommerce – Switching Price for Category
- Help wiht adding fullcalendar.io to a WordPress page
- WP Enqueue Script Error
- Enqueue JS + CSS via a child theme functions.php file?
- Remove External Links from WordPress posts Using add_filter() in Theme functions.php
- How to create a WordPress Customizer Button to Clear a Cache?
- Move product attributes after summary on single product page
- Adding A New Widget to WordPress Disables the Existing Widgets
- Javascript and Stylesheet in child page
- Problem in outputting shortcode
- Custom Nested WordPress Comments with avatar
- How to get tags and categories?
- Archive.php, and post_is_in_descendant_category
- Having problems loading Jquery in functions.php
- Functions file mods and CPU
- How do I access variables outside a function [closed]
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- How to overwrite ‘read more” text for artmag theme
- Retrieving next_post_link() and previous_post_link() in functions.php
- wp_script_add_data not working
- CF7 Remove Comma from ‘select’ ‘radio’ and ‘checkbox’ outouts
- Timeline from diferent wordpress api urls endpoint works, but diferent date