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