You can simply use var_dump()
to do this. That is how I check values inside functions and filters.
I have the following line of code in a file which I simply copy and paste where needed to dump the value of a variable
?><pre><?php var_dump( $variable_to_test ); ?></pre><?php
The pre
tags dump a nice readable array/object/string depending on the value. Inside your function you can just do
?><pre><?php var_dump($ad_posts); ?></pre><?php
after ksort( $ad_posts );
.
Just make sure to call the function somewhere if it is not hooked to some kind of hook otherwise nothing will happen
Related Posts:
- Debugging with functions.php
- Dumping variable in custom pre_gets_post function in functions.php, returns NULL
- register_sidebar_widget is deprecated since version 2.8! Use wp_register_sidebar_widget() instead
- debugging errors.. how to remedy?
- the_posts_pagination() function returns missing page numbering on some blog pages
- Getting value of variable from functions.php and debugging it
- Notice: Undefined index: post_title error
- Move product attributes after summary on single product page
- Fatal error after changes to functions.php, even with original file
- Undefined offset: 2
- Adding a second email address to a completed order in WooCommerce [closed]
- What is the difference between get_page_link and get_permalink functions?
- Suppress deprecated notices
- Possible to search by author name with default WordPress search function?
- current_cat_ancestor Alternatives
- In WooCommerce I need to modify the thankyou.php page [closed]
- Change number of posts to show on Archive page (custom post type)
- How to use wp_get_recent_posts with many post types?
- Add body class of category parent
- When is wp_trim_excerpt() called?
- Set image size on media and text block with a function
- How to update WordPress and plugins at specific day and time in PHP?
- Change parent theme file function in child themes functions.php
- Max file size not updating
- How to override filter in child theme?
- Use Exact Image Size using add_image_size
- How can I tell when a user is logged in?
- How allow users to save list of posts?
- Formatting Multiple add_theme_support Arguments
- Unable to get_the_content(); of a post in WordPress via AJAX
- Make Categories a Dropdown Menu in Media Library
- Ajax call theme functions from front
- Show excerpt for only first post in query
- How to add css class to image attached in all the posts?
- If is multiple page templates
- Is there a way to add a class to non current menu item?
- What will happen if I delete the functions.php file?
- how to add an image to the footer?
- How to properly add function called by action-hooked function to functions.php?
- Get Current User info using wp_localize_script, in functions.php
- How to add new embed handler not supported by oembed?
- How do I permanently Disable Attachment Post URL
- Need to add class=”lightbox” for every single post image
- Child Theme files – what is needed?
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Stuck on maintenance mode
- Publish/Update post is changing image links from file url to post url
- How to stop twenty fifteen theme from cropping featured images?
- How to display custom option field in woocommerce orders in admin panel?
- Update user meta of author when post content is viewed
- Don’t display html if function returns nothing
- Load custom css in functions.php causing library issue
- How i can put $_GET codes in function.php?
- In jquery use php variable to execute an enqueued jquery file
- Is there a way to direct unregistered user to registration page when click a link?
- How to stop media_sideload_image from running when deleting a post?
- I want to display latest post in marquee [closed]
- Add php code to wp_print_scripts?
- How to get an attachment id from a filename
- how to get the post ID from wp_insert_post
- Remove ‘page-numbers’ class from prev and next tags
- How can I set the SRC URL of the custom logo image?
- The Capability to choose post/page template
- How to make custom comment fields required
- How do I register a new settings page? [closed]
- Include Jquery libraries in wordpress theme?
- WooCommerce -> wc_enqueue_js not working [closed]
- Use existing image sizes for WooCommerce
- Retrieve First Image Function
- User meta and public function security
- Any adverse effects of adding apply_filters to a function?
- How can I remove page titles without removing the link in the navigation bar in twentyeleven?
- Display ACF category image on archive and single template files
- How to get taxonomy tree ids without running expensive loops
- wordpress built-in Jalali date convertor
- Change WooCommerce Payment Options From Radio Buttons to Dropdown Menu
- WordPress Function Assistance with Loop
- Using get_terms for custom taxonomy in functions.php
- Populate acf-field, depending on block name
- Add Change role button for list of user in an event
- Child theme remove parent filter in functions
- Set URL Parameter Post Layout As Default
- Exclude admins from query get posts
- I am trying to set post terms to a custom taxonomy
- Classic TinyMCE messing up only Contributor’s HTML
- How to add publish/draft button in Admin Post Lists
- Show users last read posts for each user?
- Woocommerce – change order status from on-hold to pending payment
- Disable links to images only if link is an image
- How do I integrate my Child Theme into a Custom Template?
- Sending Messages Back to the Template After Processing?
- Shortcode to eliminate and replace with
- Why are some custom javascript files working but some are not
- WordPress Javascript Widget jQuery Dependency Issue
- using enqueue_script in a shortcode isn’t working
- Filter to strip unnecessary attributes
- Will my WordPress site become vulnerable after adding this functions which allows more HTML tags for subscribers?
- get_post_class() not working well
- Add functionality to block comment authors in the Comment edit pag
- WordPress enque the same script causes the setInterval not to work