Adding:
global $post;
print_r ($post);
alone, won’t work in functions.php (becuase WP’s core functions etc wouldn’t be loaded). It would inside a relevant template file, but not in functions.php.
To make it work in functions.php, you need to do it inside an function that is hooked to an appropriate hook. The “appropriate” hook may depend on what $post
object you’re looking for (e.g. that of a single post or a post type archive), but a good way to target many situations is the wp_head hook, e.g:
add_action('wp_head', function(){
global $post;
print_r ($post);
});
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- Update Multiple Post Meta for the Same Post In One call?
- How To Ignore a Filter On Applying Filter the Content In a Function
- WooCommerce get_price returning wrong price when used via ajax
- Open Post Thumbnail in New Child Theme File in WordPress
- Display post lists in 2nd paragraph
- What are the specifics of WordPress development I need to know? [closed]
- Rename a folder via HTML POST request
- Prefix WordPress Taxonomy Tags With Hashtag Symbol Like Twitter
- Displaying friend’s posts only
- Can anyone tell me why I can’t edit a plugin when it is installed without having to re-install?
- How to create post comparison in wordpress
- Autoload via composer in plugin interference
- Deleting images through upload folder, but not deleting from media library
- Custom Shipping method not showing in checkout
- post expire after x days
- Workflow and best practice for documentation [closed]
- HELP: Integrating WP with raw PHP code once published button is hit
- Action on post publish
- Loading class files via autoload method
- WordPress plugin installation
- Display future posts?
- I would like to use create a function in my custom plugin to tell WP to use a different header
- Having separate plugins and themes folder for multi-site setup
- Getting media library popup in custom plugin admin page
- Create or Update thousands of woocommerce products via PHP
- How can I get full attachment url from wp_get_attachment_metadata?
- send_headers don’t work on wordpress multisite
- jQuery function didn’t work in my plugin
- unzip a folder on specific location and delete the zip file
- gallery option is not available in media upload box in costum theme option page
- Why is the Settings API is not saving my array of options
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- How to integrate plugin in WordPress theme
- How use %like% in sql statement wordpress
- How do you remove plugin edit option?
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin exceeds memory limit
- Adding Attachment Display Settings in custom media frame
- Write to / remove from default .htaccess file from plugin?
- Update Option Error: Notice: Undefined index
- Plugin Development sqlite or WordPress’ database
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Execute a plugin only on post pages
- How to trigger $_GET request within admin plugin page?
- How to generate video out of images via WordPress plugin
- How can I get WordPress to save comments in markdown format?
- How to ‘clone’ a wp plugin to make small changes
- How to use get_theme_mod in gutenberg editor wordpress?
- Where should I save an API key of my user when installing my plugin?
- Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
- Programatically download a plugin
- Accessing post’s meta data based on user’s click of a post
- Redirecting to home page after login as custom role WordPress
- Add keywords meta to index.php page
- Custom form action to handle data inside a plugin
- Self deactivate plugins after an action occurs
- How to get current post user id
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- WP Post Template – Templates in own folder
- The problem with WordPress Importer
- Avoid class name collision when using third party libraries in plugins?
- How do I “get the next 10 posts after post_id == x”?
- wordpress plugin is not activating from widget
- Edit Yoast SEO breadcrumbs output [closed]
- How would I go about creating a user ranked post popularity page?
- finding whether request is for post, and post id
- Conditional delete metadata does not works
- How to get the custom field value using SQL query
- How to override any plugin file in the child theme
- Help to Create a Simple Plugin to make a post
- how to display recent post by category on home page
- Unexpected add action function in WP plugin
- How to create admin setting for this small plugin
- Allow a particular user to access a particular plugin?
- admin_notices show after load completed
- Prevent WordPress from sending set-cookie http header
- submit two file input fields in the same form
- Newbie problem with adding include wp_footer
- Content-Security-Policy implementation with WordPress W3Total Cache plugin installed
- Cookie value changes back to previous value after changing
- WordPress is redirecting me to homepage
- Change plugin descriptions
- How can we get this dynamically as this folder may not be by the same name always → wp-admin
- How to display the custom post related blog by category?
- WP Forms not displaying,becomming an fatal error
- woocommerce: Customize email with item total count
- How use wp_insert_post and add og:custom tags?
- Is there any way to sync Facebook Comments and with comments on WordPress website?
- The Build menu theme is frozen with the wordpress theme
- Problem with checked box on wp car manager plugin
- Custom Plugin: How to Include Install Buttons of other 3rd Party Plugins?
- WordPress hide post from custom post-type on a single page
- Hide content for specific users with id
- How can I find related learndash course id from woocommerce product object?
- adding dynamic/multiple slug values in ‘option_none_value’