-1

i want to delete home title, also main website title on pages and posts. I i set a title for website "blablabla"

and when i crate a posts or pages with name "hello world"

The actual title of that post or page is "hello world | blablabla"

But i want to delete this | blablabla is it possible?

i Found this in theme, how should i modify it?

if ( ! function_exists( 'heatmapthemead_wp_title' ) ): function heatmapthemead_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; // Add the site name. $title .= get_bloginfo( 'name' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'heatmapthemead' ), max( $paged, $page ) ); return $title; } endif; // heatmapthemead_wp_title add_filter( 'wp_title', 'heatmapthemead_wp_title', 10, 2 ); 
6
  • 2
    Do you mean title in <title> tag? You can change it using SEO plugins like All in One SEO Pack or Yoast SEO. Commented Dec 6, 2017 at 15:51
  • Yes. No i cannot, it derives also home title with post title Commented Dec 6, 2017 at 16:03
  • Sounds like you are talking about what shows up in the tab bar in the browser page or like motivast said, in the the <title> tag? His suggesting is probably your best bet. SEO plugins are designed to allow you to modify the contents of your <title> tag to be specific to the page or the post in question. Are you looking for uniform change on all pages and posts? That would be modifying the theme's default behavior though a function that modifies the output of wp_title(). developer.wordpress.org/reference/functions/wp_title Commented Dec 6, 2017 at 16:37
  • @giodeutschland please give us something. Screenshot, theme name? Commented Dec 6, 2017 at 17:42
  • Both themes and plugins can affect your title tag, so unless you are able to share more details, we may not be able to help very effectively. :) Typically you can either use a filter on wp_title() (which will vary depending on what theme and plugins you're using), or you can create a child theme and adjust it there, if plugins aren't affecting it. Commented Dec 6, 2017 at 20:59

1 Answer 1

1

If I follow what you're explaining correctly, try adding a document title filter to the functions.php theme file. (NB: setting to only change post and pages. Search, Archive, etc, will keep original title. You can always modify accordingly.)

*** EDIT: added a filter for older themes that uses wp_title.

add_filter('wp_title', set_custom_page_title, 99999); //NB:backward compatibility with wp_title() theme function add_filter('pre_get_document_title', set_custom_page_title, 99999); function set_custom_page_title($orig_title) { if(is_page() || is_single()){ return get_the_title(); } return $orig_title; } 
13
  • thanks but i updated my answer and please see my code, where should i add your code? Commented Dec 7, 2017 at 5:22
  • This code should be placed anywhere in a functions.php file in a child theme folder (and therefore avoid editing any core theme files.) If you don't have a child theme in place and just want to test this code out quickly, you can try adding this entire snippet right after the code you shown above. i.e. right after the line: add_filter( 'wp_title', 'heatmapthemead_wp_title', 10, 2 ); *** I suggest you back-up your theme files first. Commented Dec 7, 2017 at 5:29
  • I tried but i got fatal error. Commented Dec 7, 2017 at 5:39
  • i can show my site and theme and can u help me please? I have tried hundred plugins but doesn't work Commented Dec 7, 2017 at 5:39
  • Do you see a functions.php file within your theme folder... can you add the code snippet to the bottom of that file... NB: if there is a close php tag ?> at the end put the code snippet right before that. Try this and see if you still get a fatal error or not. Commented Dec 7, 2017 at 5:47

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.