Skip Navigation

[Resolved] Create a template/view for not found page

This support ticket is created 4 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Waqar 4 years ago.

Assisted by: Waqar.

Author
Posts
#1572549

Hi

Is there a way to set a template, view etc for the page not found on WordPress?

I couldn't figure out an easy way to do this?

Thanks.

#1573001

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Matthew,

Thank you for contacting us and I'd be happy to assist.

At the moment it is not possible to directly assign a Toolset content template, view or WordPress Archive to "404 - Not found" page, but you're welcome to submit this as a feature request:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

For now, you can use the "render_view" function to show a view's output or "render_view_template" function to show a content template's output, inside the theme's "404.php" template file.

https://toolset.com/documentation/programmer-reference/views-api/#render_view
https://toolset.com/documentation/programmer-reference/views-api/#render_view_template

regards,
Waqar

#1574749

Hi

I had a look at this but this was way over my head.

I had a look into my theme and what it supports for 404 error pages, they have an existing hook to add content into the 404 page:

add_filter( 'generate_404_text','generate_custom_404_text' );
function generate_custom_404_text()
{
      return '[wpv-view name="competitions-ending-soon-list"]';
}

So I tried this but it didn't work.

How can I insert the view here? I am guessing it is fairly simply I just don't 'know how to do it as I guess you can't use Shortcodes here?

Cheers

#1575129

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thanks for the update and your understanding is correct.

The shortcodes can't be directly used in the PHP code and you'll need to include "do_shortcode" to get its output:
( ref: https://developer.wordpress.org/reference/functions/do_shortcode/ )

Example:


add_filter( 'generate_404_text','generate_custom_404_text' );
function generate_custom_404_text()
{
	return do_shortcode('[wpv-view name="competitions-ending-soon-list"]');
}

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.