Get title of page from URL

WordPress has a function called url_to_postid that may work in this situation. You can try the following (untested): <?php $url = htmlspecialchars($_SERVER[‘HTTP_REFERER’]); $back_id = url_to_postid($_SERVER[‘HTTP_REFERER’]); if( $back_id > 0 ){ $back_title = get_the_title( $back_id ); echo “<a href=”https://wordpress.stackexchange.com/questions/211840/{$url}”>Go back to the {$back_title}</a>”; }

Change title tag dynamically or within plugin?

As of WP 4.4, wp_title is deprecated. If you simply need to override your title tag, pre_get_document_title is the filter you want to use. add_filter( ‘pre_get_document_title’, ‘generate_custom_title’, 10 ); and the function would look something like this function generate_custom_title($title) { /* your code to generate the new title and assign the $title var to it… … Read more

Where do I change the ACTUAL title tag that is set in the header.php

You can do one of two things. The first, recommended way would be to use a plugin like WordPress SEO. Install it, and replace the <title> tag in your header.php file with: <title><?php wp_title(”); ?></title> Or you can change the title only for the home page by using the is_front_page or is_home conditionals. <title> <?php … Read more

How come my first blog post and my home page have the same title?

The “Reading Settings” at a domain’s wp-admin/options-reading.php is, by default, set to latest posts. So, WordPress, by default, would show the title of the post being set at “General Settings” at a domain’s wp-admin/options-general.php . In this case, Yoast’s WordPress SEO plugin would have form fields to customize it. When the “Reading Settings” are changed … Read more

Multiple Conditions for Child Page Title

Based on the comment exchange, here’s what I think you’re after: <h1><?php echo get_the_title( $post->post_parent ? $post->post_parent : $post->ID ) ?></h1> <?php if ( $list = wp_list_pages( “echo=0&child_of=$post->ID” ) ) : ?> <h2>Select a sub-page</h2> <ul> <?php echo $list ?> </ul> <?php elseif ( $post->parent ) : ?> <h2><?php the_title() ?></h2> <?php endif ?>

What code do you use to generate the text to go into the HTML title tag?

Mine is: function getDocumentTitle($separator = ” &laquo; “){ $title = get_bloginfo(‘name’); $desc = get_bloginfo(‘description’); if(is_front_page() && is_home() && !empty($desc)){ $title .= $separator.$desc; }elseif(is_home() || is_singular()){ $id = $GLOBALS[‘wp_query’]->get_queried_object_id(); if($meta = get_post_meta($id, ‘title’, true)) $title .= $separator.$meta; $title .= (empty($meta) && is_front_page() && !empty($desc)) ? $separator.$desc : $separator.get_post_field(‘post_title’, $id); }elseif(is_archive()){ if(is_category() || is_tag() || is_tax()){ $term … Read more

SEO meta description and title tag Yoast SEO

Yoast uses wp_head hook to output the meta description tag. Make sure you have this line in your <head>: <?php wp_head(); ?> For title tag, you can simplify the code by using one function call: <?php wp_title( ‘|’, true, ‘right’ ); ?> The wp_title uses a filter (same name wp_title) to let users change the … Read more

Remove site name from tag

The best (and easiest) thing to do is to use the wp_title filter. First, clean up your call to <?php wp_title(); ?> in your template. Replace what you have with this: wp_title( ‘&#124;’, true, ‘right’ ); Then, in functions.php (or in a child Theme functions.php; normal caveats apply), add the following: function wpse95147_filter_wp_title( $title ) … Read more

Site title not showing. What can I do?

Add this code to your functions.php if ( !function_exists( ‘yourtheme_setup’ ) ) { function yourtheme_setup() { /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. … Read more