the_author() str_replace error

If you want to display the author’s name outside the loop, you must use the following code snippet. First answer: Your definite answer The code below first takes the ID of the author of the post. Then it displays the author name using the ID global $post; $get_AuthorId = $post->post_author; $getUser_name = get_userdata($get_AuthorId); echo $post_author … Read more

Can I have a specific template for products even if they are standard posts and not CPT?

Filter template_include, check if the current post is a product and load the product template. Example: add_filter( ‘template_include’, function( $template ) { if ( ! is_singular() or ! get_post_meta( get_the_ID(), ‘price’, true ) ) return $template; return locate_template( ‘product-single.php’ ); }); How exactly you determine if a post is a product is up to your … Read more

How to display before H1 Title

Try to use filter like add_filter(‘the_title’, ‘new_title’, 10, 2); function new_title($title, $id) { if(‘your-post-type’ == get_post_type($id)) $title=”Add your DIV block here”; $title .= $title; return $title; }