- This topic has 13 replies, 2 voices, and was last updated 6 years, 3 months ago by Tom.
-
AuthorPosts
-
December 28, 2017 at 2:55 am #458307Hans-Hermann Loewer
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
December 28, 2017 at 9:55 am #458634TomLead DeveloperLead DeveloperHi 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-slugHope this helps 🙂
December 28, 2017 at 10:24 am #458676Hans-Hermann LoewerDear 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?
December 28, 2017 at 11:04 am #458701Hans-Hermann LoewerSorry, 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 😉
December 28, 2017 at 1:57 pm #458799Hans-Hermann LoewerI 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).
December 28, 2017 at 10:17 pm #458998TomLead DeveloperLead DeveloperAh, 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/
December 29, 2017 at 10:13 am #459452Hans-Hermann LoewerDear 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?
December 29, 2017 at 4:06 pm #459626TomLead DeveloperLead DeveloperThat’s strange – what was the specific error? I just made an adjustment that might fix it.
December 29, 2017 at 6:22 pm #459688Hans-Hermann LoewerI´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.
December 30, 2017 at 2:44 am #459816Hans-Hermann LoewerDear 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!
December 30, 2017 at 10:47 am #460065TomLead DeveloperLead DeveloperThe page slug is the last part of the URL, without any slashes.
For example:
yoursite.com/page-slug
yoursite.com/testing/another-page-slugIs 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?
December 30, 2017 at 10:53 am #460077Hans-Hermann LoewerHi Tom,
for the ad action scripts both were turned on (title and tagline).
December 30, 2017 at 11:13 am #460094Hans-Hermann LoewerDear 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!
December 30, 2017 at 9:51 pm #460310TomLead DeveloperLead DeveloperAwesome! Glad I could help 🙂
Happy New Year!
-
AuthorPosts
- You must be logged in to reply to this topic.