Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   Custom 404 Page (http://forum.bytesforall.com/showthread.php?t=14998)

pyoterguru Aug 2, 2011 11:27 PM

Custom 404 Page
 
Hi,

I need to redirect 404's to a custom 404 page saved as draft, not published.

How do I do this?

juggledad Aug 3, 2011 05:38 AM

by it's nature, a draft page won't be displayed

pyoterguru Aug 3, 2011 08:57 AM

Alright, tried saving the 404 draft page as complete web page, then uploaded to root of my server.

Typing "http://mysite.com/404.html" at the browser address bar displays the custom 404 page fine, but how do I configure Atahualpa to load this page for site 404's?

pyoterguru Aug 19, 2011 01:07 AM

Any resolution on this?

juggledad Aug 19, 2011 04:40 AM

there are two ways a 'Not Found can occur
1) a page just doesn't exist
2) you search for something that is not found

Case 1
In this case you need a 404.php file in the theme folder. Here is an example for release 3.6.7
HTML Code:

<?php
/**
 * for displaying 404 pages (Not Found).
**/
?>

<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header();
extract($bfa_ata);
?>


your code goes here

<?php get_footer(); ?>

This will format the page like any other page on your site

case 2:
In this case, edit index.php and look at the bottom where you will see
HTML Code:

<h2><?php _e('Not Found','atahualpa'); ?></h2>
<p><?php _e("Sorry, but you are looking for something that isn't here.","atahualpa"); ?></p>

just change the message to what you want

pyoterguru Aug 30, 2011 07:50 AM

Thanks a lot.

Hody Apr 27, 2012 12:55 PM

So can just the upper code be used the create a custom 404 page and has the lower part then stripped from the index.php?

freelancekonsulenten May 10, 2012 08:56 AM

I have tried to make a 404.php but it don't show the styling of the pages.
Normally my pages shows like this http://www.torbenbendixen.dk/om/
But if I type an error page http://www.torbenbendixen.dk/hfdga it doesn't show like the normal pages.

What am I doing wrong?

I am using version 3.7.6

juggledad May 10, 2012 09:57 AM

the n'normal' pages are in a post div while your 404 page is not so the styling is not being set. I suggest you look at teh 'normal' page and see teh way the text is wrapped in a <div...>...</div> and add that to your code creating the 404

freelancekonsulenten May 10, 2012 10:27 AM

Thank you for this.
I am not sure what you mean by teh?
I have searched the forum for "normal page" but can't find something that can help me.

juggledad May 10, 2012 10:53 AM

by 'normal' I was refering to the page you used in the example, the way your pages 'normaly look.

The center area is made up of come divs that have classes and the classes are styled in the theme settings. Your 404 page does not have this div of teh clsasses so the styling is not applied.

You can add a new div and style it in the css options or
look at the code and see the existing div and classes and wrap your ode in it so the theme styling will apply.

freelancekonsulenten May 11, 2012 02:53 AM

I see what you mean.
Thank you for this!!

I got it working now.

Hody May 17, 2012 03:57 AM

Quote:

Originally Posted by freelancekonsulenten (Post 84956)
I see what you mean.
Thank you for this!!

I got it working now.

Would you plese post what code you have used now in the end, I am having problems accomplishing this

freelancekonsulenten Jun 7, 2012 02:14 PM

First I use this plugin: http://wordpress.org/extend/plugins/useful-404s/

Then I create a file called 404.php, and put this code in the file:

<?php
/**
* for displaying 404 pages (Not Found).
**/
?>

<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header();
extract($bfa_ata);
?>

<div style="display: block; margin: 0 0 5px 0; padding: 10px 20px; background: white; -moz-border-radius: 10px; -khtml-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; border: solid 1px #E5E5E5;">

<?php
useful404s();
?>

</div>

<?php get_footer(); ?>

I then upload the 404.php file to the theme directory.

The code in the <div> should be the same code as your own design.

ravibandakkanavar Mar 26, 2016 02:10 PM

Hi juggledad,

Thanks a lot for your help.

For better SEO purpose, I want to return a status 404 for soft 404 not found errors.

I tried to add redirection code in the else part of index.php but I failed with all the possible types of codes. Added a 404 page also. Could you please help me with this.

juggledad Mar 26, 2016 04:57 PM

see https://codex.wordpress.org/Function.../status_header

ravibandakkanavar Mar 27, 2016 11:19 AM

Hi,

I added the following code and the page is returning 404. Thanks for this.
else /* No posts */
<?php status_header( 404 ) ?>

<h2><?php _e('Not Found','atahualpa'); ?></h2>
<p><?php _e("Sorry","atahualpa"); ?></p>

I was actually trying to return the http status 404 and also redirect it to 404.php page. I could not do it.

juggledad Mar 28, 2016 04:37 AM

That will return a 404 - check your log - AND it will run a 404.php if you have one in the atahualpa folder. However it will show inside the atahualpa page you are building.

one other thing - a search for something that is not found will NOT generate a 404
if you create a link to a page that doesnot exist, that WILL create a 404

so a search for 'this-text-does-not-exist' will (probably) just return a not found (The text in index.php)
entering a url of http://yourdomani.com/this-text-does-not-exist should result in a 404 and what ever you have in your 404.php or the text in index.php.

if you want the 404 to redirect to a completly different page without your Atahualpa settings, you will probably need to add a 404 redirect in your htaccess file (if you don't know how - do a google search)


All times are GMT -6. The time now is 04:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.