简体   繁体   中英

How to add(include) elementor created page in theme file 404.php

I created a page using elementor (named as: ' Error-page '), currently using linoor theme. What I want is to load this ' Error-page ' via theme's default 404.php file ( NOT using any plugin ). Should I just type in ' include Error-page.php ' in 404.php file to make it work?

Meta: My goal is to show my custom error page which I created using elementor(named as: Error-page) when invalid url is typed. One way of doing it is using plugin(I prefer not to do this for the time being), 2nd way could be somehow including this custom page in theme's default 404.php file

Note: Im new to wordpress

嗨,马利克,我在这里创建了一个关于您的问题简短教程视频,请看一看!

after thinking about your question, i have 2 solutions for you:

1. if you do not have code knowledge

This way is simple and safer, but have limits than other way

  • Build the 404 template with Elementor and publish it

  • Open your theme's 404.php file

  • In the very first top of the template file **(below <?php tag) paste this code:

     wp_redirect( '/your-template-slug' ); exit;
  • Save it and you're done

2. If you have basic code knowledge:

This way is a litle complex, but it alow you to using not for 404 file - but other templates (archive, categories...)

  • Install "Anywhere Elementor" plugin
  • Build the 404 template as you do with Elementor
  • Get your template php shortcode
  • Edit the theme's 404.php file to echo out your template
  • In case you need more detail guide, i have record a step by step guide video here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM