- This topic has 13 replies, 2 voices, and was last updated 1 year, 6 months ago by
David.
-
AuthorPosts
-
January 28, 2021 at 8:03 am #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’;
}January 28, 2021 at 8:51 am #1637245David
StaffCustomer SupportHi 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 pageDocumentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 28, 2021 at 9:27 am #1637289Ika
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 templateThe 404 page still showing default title and text.
Any further advice pls.
January 28, 2021 at 12:43 pm #1637463David
StaffCustomer SupportCan you share a link to the site ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 28, 2021 at 8:11 pm #1637676Ika
Hi David,
I’ve created temp login access. Details below (private info area).Tq for your time.
January 29, 2021 at 2:26 am #1637886David
StaffCustomer SupportThat login is not working for me – can you check the details and resend ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 29, 2021 at 3:27 am #1637948Ika
Roger David.
I’ve created a new one (which i have tested as well) – refer below.January 29, 2021 at 3:57 am #1637976David
StaffCustomer SupportCan you disable the 404 plugin and any other functions that may be redirecting the 404 template.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 29, 2021 at 4:23 am #1637992Ika
Done David, i’ve deactivated these plugins > Redirection, 404page and coming soon/maintenance plugin.
January 29, 2021 at 4:46 am #1638012David
StaffCustomer SupportAah 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.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 29, 2021 at 6:13 am #1638085Ika
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.
January 29, 2021 at 6:58 am #1638381David
StaffCustomer SupportAah
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/Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/January 29, 2021 at 7:12 am #1638393Ika
You’ve been a great help David.
That works.Tq, tq so much.
Have a nice day David and be safe.
January 29, 2021 at 7:21 am #1638409David
StaffCustomer SupportAwesome – glad to be of help
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.