badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

change 404 text

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #11778
    Hellen
    Participant

    Hi
    I want to change the 404 text. So i copied the function attitude_display_404_page_content() into my child theme’s functions.php.

    functions.php
    
    if ( ! function_exists( 'attitude_display_404_page_content' ) ) :
    function attitude_display_404_page_content() {
    ?>
    	... my text...
    <?php
    }
    endif

    then i get this error: Fatal error: Cannot redeclare attitude_display_404_page_content() in /content-extensions.php.

    What am I doing wrong?

    thanks in advance.

    #11785

    After endif semicolon is needed.
    This error shows that this functions is already declared, so you are getting this error. You are not able to declare same function twice.

    you need to hook function too
    add_action( ‘attitude_404_content’, ‘attitude_display_404_page_content’, 10 );

    Thank you!

    #11796
    Hellen
    Participant

    Hi,

    this is my complete functions.php in the child-theme directory:

    <?php
    // Exit if accessed directly
    if ( !defined('ABSPATH')) exit;
    
    /* Add custom functions below */
    
    if ( ! function_exists( 'attitude_display_404_page_content' ) ) :
    
    add_action( 'attitude_404_content', 'attitude_display_404_page_content', 10 );
    
    function attitude_display_404_page_content() {
    ?>
    	<div id="content">
    		<header class="entry-header">
    			<h1 class="entry-title"><?php _e( 'Error 404-Page NOT Found', 'attitude' ); ?></a></h1>
    		</header>
    		<div class="entry-content clearfix" >
    			<p><?php _e( 'This is my own text.', 'attitude' ); ?></p>
    			<h3><?php _e( 'lorem ipsum', 'attitude' ); ?></h3>			
    			<h3><?php _e( 'Please try the following instead:', 'attitude' ); ?></h3>
    			<p><?php _e( 'Check for a mis-typed URL error, then press the refresh button on your browser.', 'attitude' ); ?></p> 
    		</div><!-- .entry-content -->
    	</div><!-- #content -->
    <?php
    }
    endif;

    I am still getting the same error.

    #11802

    i think you don’t need this line of code
    if ( ! function_exists( ‘attitude_display_404_page_content’ ) ) :

    endif;

    thank you!

    #11806
    Hellen
    Participant

    Hi,

    I removed the IF-condition like you said, my functions.php now looks like this :

    <?php
    // Exit if accessed directly
    if ( !defined('ABSPATH')) exit;
    
    /* Add custom functions below */
    
    add_action( 'attitude_404_content', 'attitude_display_404_page_content', 10 );
    
    function attitude_display_404_page_content() {
    ?>
    	<div id="content">
    		<header class="entry-header">
    			<h1 class="entry-title"><?php _e( 'Error 404-Page NOT Found', 'attitude' ); ?></a></h1>
    		</header>
    		<div class="entry-content clearfix" >
    			<p><?php _e( 'This is my own text.', 'attitude' ); ?></p>
    			<h3><?php _e( 'lorem ipsum', 'attitude' ); ?></h3>			
    			<h3><?php _e( 'Please try the following instead:', 'attitude' ); ?></h3>
    			<p><?php _e( 'Check for a mis-typed URL error, then press the refresh button on your browser.', 'attitude' ); ?></p> 
    		</div><!-- .entry-content -->
    	</div><!-- #content -->
    <?php
    }

    But i am still getting this error :
    Fatal error: Cannot redeclare attitude_display_404_page_content() (previously declared in …/wp-content/themes/attitude-pro/library/structure/content-extensions.php on line 966.

    somehow i cannot redeclare the function???

    #11841

    Use this in your functions.php

    // Unhook default Thematic functions
    function unhook_thematic_functions() {
        // Don't forget the position number if the original function has one
    
    remove_action( 'attitude_404_content', 'attitude_display_404_page_content', 10 );
    
    }
    add_action('init','unhook_thematic_functions'); // removes the header content by using hook attitude_header
    
    add_action( 'attitude_404_content', 'attitude_child_display_404_page_content', 10 );
    /**
     * function to show the footer info, copyright information
     */
     
     
    function attitude_child_display_404_page_content() {      ?>   
    <div id="content">
    		<header class="entry-header">
    			<h1 class="entry-title"><?php _e( 'Error 404-Page NOT Found', 'attitude' ); ?></a></h1>
    		</header>
    		<div class="entry-content clearfix" >
    			<p>Thank you</p> 
    		</div><!-- .entry-content -->
    	</div><!-- #content -->
      <?php 
    }

    Thank you!

    #11914
    Hellen
    Participant

    Thank you very much, this was the solution that I needed!!!

    kind regards!

    #11929

    That’s great Hellen,

    Thank you!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.