Show post object of any page in frontend

Because in functions.php, it is too early to just run the print_r(), you may run it within a init hook like this: Placing it inside theme’s functions.php add_action( ‘init’, ‘test_trace’ ); function test_trace() { global $post; print_r($post); }

How can I see $post object in frontend from functions.php?

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 … Read more

Redirecting wordpress search query to archive page

Simply make an HTML form in Elementor on the archive page where you want to search. Code: <form class=”zohaib-search-form” role=”search” action=”/courses” method=”get”> <input placeholder=”Search..” name=”s” type=”search”> <button type=”submit”><i class=”fas fa-search”></i></button> **Note:** name property of input should be ‘s’ because the search query is looking for key ‘s’ to get and run it. Replace the action … Read more

How to add a custom class attribute into code wrapper? [duplicate]

To add your custom class to the old posts at once, you can do this via “the_content” filter and using preg_replace or preg_replace_callback function to do a REGEX replacement. A working Example: add_filter( ‘the_content’, function( $content ){ // Don’t do anything if we’re not in a single post if(! is_singular()){ return $content; } $customClass=”custom-class”; return … Read more

Permalink for specific post type

If it is an option to use a plugin, here is one with over 100,000 installs, so it seems to do a good job: https://wordpress.org/plugins/custom-post-type-permalinks/ It is exactly solving your client’s wish. After installing and activating it, go to Settings -> Permalinks -> and scroll down to the section Permalink Settings for Custom Post Types.

Posts missing on author page

It’s best not to edit theme files directly, because when you update the theme, your changes are lost. Instead, if you need to change things, create a child theme and you can do whatever you need there. To restore the previous file you can either download a fresh copy of your theme, or look through … Read more