ThemeShaper Forums » Thematic

[closed]

How do I customize 404 page

(19 posts)
  • Started 9 years ago by iHusband
  • Latest reply from onelittlemoose
  • This topic is not resolved
  1. iHusband
    Member

    How do I customize the 404 page in Thematic so I can show an image, a site map, or an internal search box? Thanks in advance for any advice you can give me.

    Posted 9 years ago #
  2. iHusband
    Member

    The WordPress website provides a tutorial for this:

    http://codex.wordpress.org/Creating_an_Error_404_Page

    Posted 9 years ago #
  3. iHusband
    Member

    It seems I will need more than that WordPress tutorial to customize the Thematic 404 page. So any instruction will be greatly appreciated.

    Posted 9 years ago #
  4. Me too,

    How do I customize the 404 page in Thematic so I can show an image, a site map, or an internal search box? Thanks in advance for any advice you can give me.

    Using a customized child theme based on the bybt theme.

    Posted 9 years ago #
  5. Hi-

    You could:

    function remove_thematic_404_content() {
              remove_action('thematic_404','thematic_404_content');
    {
    add_action('init','remove_thematic_404_content');

    and then add this changing it to suit your needs...

    function my_404_content() { ?>
    <?php thematic_postheader(); ?>
    
    <div class="entry-content">
    <p><?php _e('Apologies, but we were unable to find what you were looking for. Perhaps  searching will help.', 'thematic') ?></p>
    </div>
    
    <form id="error404-searchform" method="get" action="<?php thm_bloginfo('home', TRUE) ?>">
    <div>
    <input id="error404-s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="40" />
    <input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Find', 'thematic') ?>" />
    </div>
    </form>
    <?php } // end thematic_404_content
    
    add_action('thematic_404','my_404_content');

    -Gene

    Posted 9 years ago #
  6. Hi Gene and thanks for the suggestion,

    Just trying to get your version to work then I can modify to call my text and custom page.

    I am having a bit of a problem with the syntax.

    Parse error: syntax error, unexpected '}' in /home/relax/public_html/cookingsalmon/wp-content/themes/byty-cooksalmon/functions.php on line 55

    here is my functions code

    <?php
    /* Add a home link to top memu */
     function childtheme_menu_args($args) {
        $args = array(
    'show_home'=>'Home',
            'sort_column' => 'menu_order',
            'menu_class' => 'menu',
            'echo' => true
        );
    	return $args;
    }
    add_filter('wp_page_menu_args','childtheme_menu_args');
    ?>
    <?php
    /* adds firs 55 words from post to meta description */
    function wanna_use_autoexcerpt() {
     return TRUE;
    }
    add_filter('thematic_use_autoexcerpt', 'wanna_use_autoexcerpt');
    ?>
    <?php
    /* Register Top Add Wiget */
    function add_top_ad() {
    ?>
    
    <div id="top_ad">
    
    </div>
    
    <?php
    }
    
    add_action('thematic_belowheader', 'add_top_ad');
    ?>
    
    /* Get Rid of Default 404 page */
    function remove_thematic_404_content() {
              remove_action('thematic_404','thematic_404_content');
    {
    add_action('init','remove_thematic_404_content');
    
    /* New 404 page content */
    function my_404_content() { ?>
    <?php thematic_postheader(); ?>
    
    <div class="entry-content">
    <p><?php _e('Apologies, but we were unable to find what you were looking for. Perhaps  searching will help.', 'thematic') ?></p>
    </div>
    <form id="error404-searchform" method="get" action="<?php thm_bloginfo('home', TRUE) ?>">
    <div>
    <input id="error404-s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="40" />
    <input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Find', 'thematic') ?>" />
    </div>
    </form>
    <?php }
    /* end thematic_404_content */
    add_action('thematic_404','my_404_content');
    ?>

    line 55 is the <?php }

    Posted 9 years ago #
  7. I didn't check it for functionality but I cleaned it up a bit so it will parse.

    <?php
    /* Add a home link to top memu */
     function childtheme_menu_args($args) {
        $args = array(
    	'show_home'=>'Home',
            'sort_column' => 'menu_order',
            'menu_class' => 'menu',
            'echo' => true
        );
    	return $args;
    }
    add_filter('wp_page_menu_args','childtheme_menu_args');
    
    /* adds firs 55 words from post to meta description */
    function wanna_use_autoexcerpt() {
     	return TRUE;
    }
    add_filter('thematic_use_autoexcerpt', 'wanna_use_autoexcerpt');
    
    /* Register Top Add Wiget */
    function add_top_ad() {?>
    	<div id="top_ad">
    	</div>
    <?php }
    add_action('thematic_belowheader', 'add_top_ad');
    
    /* Get Rid of Default 404 page */
    function remove_thematic_404_content() {
    	remove_action('thematic_404','thematic_404_content');
    }
    add_action('init','remove_thematic_404_content');
    
    /* New 404 page content */
    function my_404_content() { ?>
    	<?php thematic_postheader(); ?>
    	<div class="entry-content">
    	<?php _e('Apologies, but we were unable to find what you were looking for. Perhaps  searching will help.', 'thematic') ?>
    
    	</div>
    	<form id="error404-searchform" method="get" action="<?php thm_bloginfo('home', TRUE) ?>">
    	<div>
    	<input id="error404-s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="40" />
    	<input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Find', 'thematic') ?>" />
    	</div>
    	</form>
    	<?php }
    	/* end thematic_404_content */
    add_action('thematic_404','my_404_content');
    ?>
    Posted 9 years ago #
  8. Thank you for your effort. I had already took the easy way out and added the 404.php page to my child directory and edited it directly. But I will be implementing your improvements before long.

    Posted 9 years ago #
  9. lqunta
    Member

    Greetings All,

    Pardon me if I may be asking a rather simplistic question. Probably, I may not be thinking right today [hello....where did I leave my brains today]!

    If one want's to customize the 404 page, probably as above, should they:

    - have an actual 404.php in the child theme directory?
    - have an actual 404.php in the child theme directory, and, the code in the functions.php page?
    - just have the code in the functions.php page?

    have tried with just the code in the functions.php page, and......no joy!

    Cheers,
    LQunta

    Posted 9 years ago #
  10. lqunta-

    Complexities abound yes you could do all the above:

    -If you're new to thematic you may find using a 404 template that adding 404.php in your child theme is a more straight forward approach.

    -You could have a custom 404.php that uses functions from your functions.php.

    -Or my preferred approach would be could use your child theme's functions.php to remove and rebuild the 404 page content like I demonstrated above.

    -Gene

    Posted 9 years ago #
  11. curobs
    Member

    Hi-I applied em hr's function for the custom my_404_content provided above, but am also getting the same syntax error that LQunta reported. Here's the function as it appears in my child function.php file. (if I take these two functions out, the default 404 page appears fine.) Can anyone suggest how to address the "unexpected '}'" error referring to line containing the last "<?php }"? Thanks!

    // Get rid of Default 404 page
    function remove_thematic_404_content() {
    remove_action('thematic_404','thematic_404_content');
    }
    add_action('init','remove_thematic_404_content');

    // New 404 page content
    function my_404_content() { ?>
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php _e('Apologies, but we were unable to find what you were looking for. Perhaps searching will help.', 'thematic') ?>

    </div>
    <form id="error404-searchform" method="get" action="<?php thm_bloginfo('home', TRUE) ?>">
    <div>
    <input id="error404-s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="40" />
    <input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Find', 'thematic') ?>" />
    </div>
    </form>
    <?php }
    // end thematic_404_content
    add_action('thematic_404','my_404_content');
    ?>

    Posted 9 years ago #
  12. Hi curobs,

    ACk! I included a function from the svn thm_bloginfo() causing a fatal error when used with the .9.5.1 version. Sorry for the inconvenience.

    Try this code:

    function my_404_content() { ?>
    <?php thematic_postheader(); ?>
    <div class="entry-content">
    <?php _e('Apologies, but we were unable to find what you were looking for. Perhaps searching will help.', 'thematic') ?>
    
    </div>
    <form id="error404-searchform" method="get" action="<?php bloginfo('home') ?>">
    <div>
    <input id="error404-s" name="s" type="text" value="<?php echo wp_specialchars(stripslashes($_GET['s']), true) ?>" size="40" />
    <input id="error404-searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Find', 'thematic') ?>" />
    </div>
    </form>
    <?php }
    // end thematic_404_content
    add_action('thematic_404','my_404_content');

    -Gene

    Posted 9 years ago #
  13. curobs
    Member

    Hi Gene, thanks so much, and also for sharing the code! It works fine now.

    Posted 9 years ago #
  14. Hi,

    Thanks for the info on this post, I would like to edit 404 page via CSS , so I was looking for the page slug name. I have found info for styling here http://themeshaper.com/thematic/guide/?page_id=64 and this seems to be the ref name, error404.

    When i try

    body.slug-error404 #above-leaderaside {
    display: none;
    }

    it does not work, I have tried numerous other combinations. Is it possible to style this page in this way ?

    Many thanks, best wishes, and happy new year !

    tom

    Posted 9 years ago #
  15. Hi-

    Try:

    .four04 #above-leaderaside {
    display: none;
    }
    Posted 9 years ago #
  16. PERFECT, thanks em hr ! Not sure where you got that from but it works. Thanks so much f your help and reply.

    best wishes,

    tom

    Posted 9 years ago #
  17. If you want to see where all the magic happens take a look at this file: thematic/library/extensions/dynamic-classes.php

    To see how this manifests itself on your site go to any page even a 404 and look at the source code for the <body class="">

    Glad to help,
    Gene

    Posted 9 years ago #
  18. jjfossey
    Member

    I am using the latest version of Thematic and am trying to change the messaging on the 404.php page, but I am having trouble. I notice that there is a block of code that looks like this:

    <?php
    // action hook for the 404 content
    thematic_404()
    ?>

    Can anyone tell me what this is and if it can be edited? If I remove it, the search form disappears. Basically, I want to change the default messaging on the 404 page from "Apologies, but we were unable to find what you were looking for. Perhaps searching will help." to something else.

    Posted 8 years ago #
  19. onelittlemoose
    Member

    If you're just looking to change the message, as I was, I've discovered a little function that allows you to do just that.

    In my case I wanted to remove the search box in the 404 page and just have a direct link back to the home page.

    // to customize the message on the 404 page not found
    function childtheme_override_404_content() { ?>
       	<?php thematic_postheader(); ?>
    	<div class="entry-content">
    	<p><?php _e('Apologies, but we were unable to find what you were looking for.', 'thematic') ?></p>
            <p><a href="http://www.mywebaddress.com">Click here to return to the home page.</a></p>
    	</div><!-- .entry-content -->
    	<?php }
    add_action('thematic_404_content','childtheme_override_404_content')

    Hope this helps.

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.