[Support request] Edit 404 Page title and content.

Home Forums Support [Support request] Edit 404 Page title and content.

Home Forums Support Edit 404 Page title and content.

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1637179
    Ika

    Hi,
    Hope you and your family in good health.

    FYI, i’m, using GeneratePress’ Artic theme and i intend to change the 404 page title and content.
    i pasted these (refer below) onto code snippet plugin however the 404 still display the default title and content.

    Pls advise what else i need to do to customise the 404 page.

    Note:
    i have also tried the 404 page plugin as recommended in the forum but still not able to customise the 404 page.

    ……………………………………

    add_filter( ‘generate_404_title’,’generate_custom_404_title’ );
    function generate_custom_404_title()
    {
    return ‘This is new title’;
    }

    add_filter( ‘generate_404_text’,’generate_custom_404_text’ );
    function generate_custom_404_text()
    {
    return ‘this is new txt’;
    }

    #1637245
    David
    Staff
    Customer Support

    Hi there,

    you can use a Block Element ( or hook element ) to create your 404 content:

    https://docs.generatepress.com/article/block-element-overview/

    Select the Custom Hook and add this: generate_do_template_part
    Set the Display Rules to 404 page

    #1637289
    Ika

    Hi David,
    Tq for prompt reply.

    Here’s what i did.

    I created element (block).
    Block type > Hook.
    Custom Hook Name > generate_do_template_part
    Location > 404 template

    The 404 page still showing default title and text.

    Any further advice pls.

    #1637463
    David
    Staff
    Customer Support

    Can you share a link to the site ?

    #1637676
    Ika

    Hi David,
    I’ve created temp login access. Details below (private info area).

    Tq for your time.

    #1637886
    David
    Staff
    Customer Support

    That login is not working for me – can you check the details and resend ?

    #1637948
    Ika

    Roger David.
    I’ve created a new one (which i have tested as well) – refer below.

    #1637976
    David
    Staff
    Customer Support

    Can you disable the 404 plugin and any other functions that may be redirecting the 404 template.

    #1637992
    Ika

    Done David, i’ve deactivated these plugins > Redirection, 404page and coming soon/maintenance plugin.

    #1638012
    David
    Staff
    Customer Support

    Aah you have this CSS:

    .error404 #page {
        display: none;
    }

    which is hiding your Hook. I forced a 404 by going to a link that doesn’t exist and removed that CSS in developers tools and the element is displaying.

    #1638085
    Ika

    Tq so much spending your time on this David.

    I did similar test like yours ie by pasting a url of post that no longer exist. The custom error message appears.

    However, the Default Message appears if search not found (i.e when i try to search sth using the search box). I tested this after i’ve cleaned cache and did it in incognito mode just to be sure.

    Your advice pls.

    #1638381
    David
    Staff
    Customer Support

    Aah No Results is a completely differ template – it uses the search template, but there is no display rule for that. Instead you would do this:

    1. Remove the Display Rule location. So there is no location chosen.
    2. Examine the Blocks Elements URL and get the ID eg. 10
    3. Save the Element
    4. Then you will need to add this PHP Snippet to your site:

    add_filter( 'generate_block_element_display', function( $display, $element_id ) {
        if ( 10 === $element_id && is_search() ) {
            global $wp_query;
    
            if ( ! $wp_query->found_posts ) {
                $display = true;
            }
        }
    
        return $display;
    }, 10, 2 );

    Change the 10 in the code to match your block elements ID.

    Adding PHP:
    https://docs.generatepress.com/article/adding-php/

    #1638393
    Ika

    You’ve been a great help David.
    That works.

    Tq, tq so much.

    Have a nice day David and be safe.

    #1638409
    David
    Staff
    Customer Support

    Awesome – glad to be of help

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