Archived topic
Need a new website-title for a second main page
13 replies · Started by Hans-Hermann Loewer on December 28, 2017
Dear Tom,
I must find a way to have a SECOND main-page as a landingpage within one hosting-package and one wordpress-project with a NEW individual website-title and subtitle – without changing on the FIRST mainpage of the project.
The red arrows in the screenshot shows which title and subtitle I mean, cause there are a lot of things called „title“ in wordpress. Link to the screenshot:
https://www.warzen-besprechen-berlin.de/wp-content/uploads/screenshot.png
I´m just a webmaster, no programer and php-specialist like you. Please can you explain the solution in a step-by-step way? That would be great!
Thanks in advance, Hermann
Hi Hermann,
Since your title and tagline are turned off by default, we can use a simple filter to turn them on under certain conditions.
For example:
add_filter( 'option_generate_settings', 'tu_show_title_tagline' );
function tu_show_title_tagline( $options ) {
if ( is_page( 'your-page-slug' ) ) {
$options['hide_site_title'] = '';
$options['hide_tagline'] = '';
}
return $options;
}
You just need to change your-page-slug to match yourwebsite.com/your-page-slug
Hope this helps :)
Dear Tom,
think it helps not really, cause your solution means that the site-title and tagline must be turned off for the FIRST landingpage too.
No chance to have two different site-titles and taglines, one for the FIRST page and one for the SECOND page within one wordpress-project?
Sorry, me again (cause I´m no program-champ like you):
Where can I put the lines in to use the filter?
The functions.php of the child-theme „mantle“ doesn´t take the filter.
Hermann ;-)
I tried your code as a snippet (plugin: code snippets) but couldn´t get the promised result.
The title and subtitle are still where they were before.
In wordpress 4.9.1 (DE) its no longer allowed to change the content of a plugin it seams; the „pluginception“ plugin can not be used to put the code in, it is impossible to save it (wordpress avoids it).
Ah, if you want to change the site title and tagline depending on the page, you can do this:
add_action( 'option_blogname', 'tu_adjust_blogname' );
function tu_adjust_blogname( $name ) {
if ( is_page( 'your-page-slug' ) ) {
return 'Custom title text';
}
if ( is_page( 'another-page-slug' ) ) {
return 'More custom title text';
}
return $name;
}
add_action( 'option_blogdescription', 'tu_adjust_blogdescription' );
function tu_adjust_blogdescription( $name ) {
if ( is_page( 'your-page-slug' ) ) {
return 'Custom tagline text';
}
if ( is_page( 'another-page-slug' ) ) {
return 'More custom tagline text';
}
return $name;
}
As for adding the code, if WP is preventing you from creating a plugin, you can use a plugin like this: https://en-ca.wordpress.org/plugins/code-snippets/
Dear Tom,
I implemented the first solution into the clients site, and the result was 1 day off (fatal php error line 9 said the error-logs of the hostprovider).
The second solution doesn´t do it too. Perhaps I wasn´t good enough. Did you test it before?
That's strange - what was the specific error? I just made an adjustment that might fix it.
I´ll sent you the details by mail, cause there are a lot of clients data within the code.
The fixed second solution (changing site title and subline) would be the best, if it will do its job.
Dear Tom,
perhaps I made mistakes with the code?! But I tried variations.
Some questions:
@ if ( is_page( 'your-page-slug' )
There are several things I don´t know how to do:
-> May I let 'your-page-slug' blanc that means '' for the startpage = domainname in case I want to change title and / or tagline there too?
(seams as if that would be the same effect on every page, that´s not defined in the code (sitemap, contact …), but that´s not so important.
-> What about the slashes at the beginning and at the end of a page-slug? I didn't put them inside. right way? That means if the slug would be [domainname]/second-page/, I have to put in only second-page not /second-page/ right?
-> The so called „page-slug“ is the same as defined at the end of the pages permalink. right? Even if it is different (written without capitals for example) to the Pages title on top of the page (here: not Website title)?
-> When I tried your two add_action fields in the code snippet (your idea was brilliant, but I could't get the result), it sometimes showed a 'Custom title text' (only ONE, never the 'More custom title text' on another page too, in the head of that other page) but allways hid the 'tagline text' completely.
Thanks in advance for your answer!
The page slug is the last part of the URL, without any slashes.
For example:
yoursite.com/page-slug
yoursite.com/testing/another-page-slug
Is the tagline turned on by default in the Customizer? If so, can you show me the code you're using so I can see why the tagline isn't showing up?
Hi Tom,
for the ad action scripts both were turned on (title and tagline).
Dear Tom,
did you change anything in the code postet before?
I tried it again and it´s OK now.
Both appear Title and Tagline!
You're the Best!
You saved my life! ;-)
Thank you so much!
Have a nice start into a great New Year!
Awesome! Glad I could help :)
Happy New Year!