[Resolved] Need a new website-title for a second main page

Home Forums Support [Resolved] Need a new website-title for a second main page

Home Forums Support Need a new website-title for a second main page

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #458307
    Hans-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

    GP Premium 1.5.6
    #458634
    Tom
    Lead Developer
    Lead Developer

    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 🙂

    #458676
    Hans-Hermann Loewer

    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?

    #458701
    Hans-Hermann Loewer

    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 😉

    #458799
    Hans-Hermann Loewer

    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).

    #458998
    Tom
    Lead Developer
    Lead Developer

    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/

    #459452
    Hans-Hermann Loewer

    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?

    #459626
    Tom
    Lead Developer
    Lead Developer

    That’s strange – what was the specific error? I just made an adjustment that might fix it.

    #459688
    Hans-Hermann Loewer

    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.

    #459816
    Hans-Hermann Loewer

    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!

    #460065
    Tom
    Lead Developer
    Lead Developer

    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?

    #460077
    Hans-Hermann Loewer

    Hi Tom,

    for the ad action scripts both were turned on (title and tagline).

    #460094
    Hans-Hermann Loewer

    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!

    #460310
    Tom
    Lead Developer
    Lead Developer

    Awesome! Glad I could help 🙂

    Happy New Year!

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.