Print post title with markup

Using your example, you could… <h4><?php echo get_the_title( $post_id ); ?></h4> Or $h4 = get_the_title(); echo ‘<h4>’ . $h4 . ‘</h4>’; More on get_the_title(). Or you could use the_title(). the_title( ‘<h4>’, ‘</h4>’ );

disallow publish posts with special title

The “easy” answer is: put a filter on it. add_action( ‘transition_post_status’, ‘my_function’, 10, 3 ); function my_function( $new_status, $old_status, $post ) { if ( ‘publish’ !== $new_status or ‘publish’ === $old_status ) return; if ( ‘post’ !== $post->post_type ) return; // restrict the filter to a specific post type $title = $post->post_title; $restricted_title = “title … Read more

Loop doesn’t show title of second post and posts thereafter

The code posted for your index.php file contains an error. The WordPress function the_post() is called twice in each iteration. As this function iterates the post index and sets up the conditionals for each post, calling this twice is the likely cause of your problem. Remove the second instance of the_post() immediately after your H2. … Read more

Gutenberg – Title field required

You could use PluginPrePublishPanel to check for the title and lock publishing if it’s empty. Have a look at the accepted answer here for an example of locking the post – Add pre-publish conditions to the block editor For your example you could modify the checking portion as follows: const { registerPlugin } = wp.plugins; … Read more

How to solve the site tag being displayed twice?

You are getting the two <title> tags most likely because your theme has the title-tag support which automatically adds the title tags in the document head. Excerpt from the above linked page on Make WordPress Core: Adding titles to themes Starting with 4.1 and Twenty Fifteen, the recommended way for themes to display titles is … Read more

Shortcode To Display Post Custom Field Value in Post Title, Post Content

the_title filter takes two parameters, one of them is the ID of the post for which it was called. Something like that should work. add_filter( ‘the_title’, ‘se385007_title_filter’, 20, 2 ); function se385007_title_filter( $title, $post_id ) { $new_title = str_replace( “[geo_name]”, “[geo_name post_id=$post_id]”, $title ); return do_shortcode( $new_title ); )