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
- What are the differences between WPINC and ABSPATH?
- Using require_once in a Plugin?
- What is the correct way for a theme to support plugin UIs?
- How to call “page specific menu items” in template [closed]
- Publish Post After Click On A Link
- Should I use RIPS tool to test my themes and plugins?
- Action on post publish
- Having separate plugins and themes folder for multi-site setup
- How can I get full attachment url from wp_get_attachment_metadata?
- 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)
- Scope for PHP Variables Assigned in functions.php or a plugin
- Plugin Development sqlite or WordPress’ database
- Add keywords meta to index.php page
- Pulling data from custom plugin settings using PHP shortcode and Javascript
- wordpress plugin is not activating from widget
- Creating a custom post type, adding custom meta fields, preventing all future editability of posts of this type
- WordPress shows error related to allow_url_fopen
- How to replace WordPress Media Upload Window with user’s device window?
- How to create a code editor for my plugin .?
- How to create a custom post type that contains another custom post type?
- Setup wp_schedule_event within a custom plugin
- how to force tag page layout to use same as search layout?
- Great blogs site resources/tutorial for WordPress Developers? [closed]
- Issue running db create table query from static method
- execute function after one completed
- How to make multiple admin pages for one plugin?
- Allowing users to Sign-up > Login > Post articles that need approval
- Redeclare function after plugin activation
- Set Multiple Meta Values as an Array Using dispatch( ‘core/editor’ ).editPost() Call in Gutenberg/JS
- Why is it important to check for isset and is_array before checking in_array in this example?
- How to add/change (woocommerce) product tab icon
- Comment “like” problem – “users who like this” avatar linking to current user profile instead of “liker’s” profile
- I want to generate the pdf and save it in library?
- How to call external functions from a PHP script in a WordPress plugin?
- How to write to a separate PHP file in plugin settings
- WordPress API functions not working at AJAX functions.php call
- Don’t load the theme for a page FROM a plugin EDITED
- Create “new pages” within the admin section of plugin
- WordPress plugin with its own “site”/theme
- More gentle way to hook WordPress custom url
- How to display results from a data table with an encrypted user id?
- How to add custom function to pluggable.php
- How to get Recent Post From Each Category with Thumbnail?
- How to displaying Custom image, text and default image logo from Redux Framework option panel
- Xamp installed local wordpress not allowing to publish or install plugin
- How to Call Specific .PHP file on add_submenu_page selection in Plugin Development?
- How to Add text value in Automatically in this conditions?
- Checkbox show / hide output result
- Is it possible to pin a post in second position from top
- save_post_product action not firing
- How to get the custom field value using SQL query
- admin_notices show after load completed
- Newbie problem with adding include wp_footer
- How use wp_insert_post and add og:custom tags?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- How to change “Read More” text?
- Using id to show item
- How much PHP and MySQL or MariaDB knowledge should I know to start writing WordPress themes and plug-ins and whatever else a beginner can edit?
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- Generate and send ICS file through WordPress
- Is admin section completely customizable in terms of styling?
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- Change pricing in Woocommerce based on Category and Product [closed]
- WordPress environment not loading properly
- WordPress not displaying information on post sent from custom admin form
- Creating a user ‘add custom field’ section
- Saving an array to get_options
- How to show post attachment image
- Doing action based on input from options menu
- Help me with my first very basic plugin
- My wordpress website admin panel loads very slow, what can i do about that? [closed]
- PHP $_session is not work in wordpress
- How to generate a responsive output from plugin?
- How to add custom html to the Media > Attachment Details modal?
- manage_{taxonomy}_custom_column not working
- add_meta_box showing blank screen in my page
- How to override plugin function in code snippets WordPress
- How to make content as required in custom post type?
- How to create a “Most Popular” & “Latest” TAB in WordPress
- warning wp session
- What are Seeds? [closed]
- Use inline callable for hooks and filters
- Error in using ‘admin_enqueue_scripts’ action through a class