• Resolved JacobTheDev

    (@revxx14)


    I’m not seeing any settings for controlling the title on a 404 page, is this something that’s possible with this plugin?

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Steve M

    (@wpsmort)

    Hi @revxx14, there is no setting for this within the plugin. You can use our aioseo_title filter to set the SEO title for the 404 page – https://aioseo.com/docs/aioseo_title/

    You’d use the is_404() conditional tag in WordPress to target just the 404 page – https://codex.www.ads-software.com/Conditional_Tags#A_404_Not_Found_Page

    Thread Starter JacobTheDev

    (@revxx14)

    Hmm, I’ve added the following but it doesn’t seem to be working. If I do something like return "Hello World";, it does show up on other pages, but 404 always displays “Page not found |”. Not sure what’s going on… any ideas? Inheader.php, I do have<title><?php wp_title("|", true, "right"); ?></title>, is that correct?

    /**
     * Fix 404 page title
     *
     * @param string $title
     * @return string
     */
    function grammar_book_aioseo_title($title) {
        if (is_404()) {
            $title = wp_strip_all_tags(__("404: Page Not Found - The Blue Book of Grammar and Punctuation", "grammar_book"));
        }
    
        return $title;
    }
    add_filter("aioseo_title", "grammar_book_aioseo_title", 10, 1);
    • This reply was modified 3 years, 5 months ago by JacobTheDev.
    • This reply was modified 3 years, 5 months ago by JacobTheDev.
    Plugin Support Steve M

    (@wpsmort)

    @revxx14 I do apologize, it turns out that we’re not writing the title tag for the 404 page so our filter won’t work here.

    Thread Starter JacobTheDev

    (@revxx14)

    Ah, so I’ll have to just do it manually then, alright… hopefully you guys can add a setting for this in the future, seems like a pretty common thing people would want to do.

    Thanks for the help

    @revxx14 write the solution please.

    Thread Starter JacobTheDev

    (@revxx14)

    @alexe5 You’d just do something like this in your header.php…

    <?php if (is_404()): ?>
    <title><?php esc_attr_e(“404: Page Not Found | My Website”); ?></title>
    <?php endif; ?>

    @revxx14 Unfortunately it doesn’t work because All in One SEO is active.

    Plugin Author arnaudbroes

    (@arnaudbroes)

    @alexe5 AIOSEO does not affect the title for 404 pages in any way so the code snippet above should work. You might need to verify if it’s actually running where you added it in your theme.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How do I change the title for the “404” page?’ is closed to new replies.