0

I have been trying to do this for hours now but just can't get this to work. What I am trying to do is change the copyright info in my wordpress theme which is being pulled from wp-content\themes\corporate-plus\acmethemes\hooks\footer.php with the below code.

    <?php
/**
 * Footer content
 *
 * @since Corporate Plus 1.0.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_footer' ) ) :

    function corporate_plus_footer() {

        global $corporate_plus_customizer_all_values;
        ?>
    <div class="clearfix"></div>
    <footer class="site-footer">
        <div class="container">
            <div class="bottom">
                <?php
                if(
                    is_active_sidebar('footer-col-one') ||
                    is_active_sidebar('footer-col-two') ||
                    is_active_sidebar('footer-col-three') ||
                    is_active_sidebar('footer-col-four')
                ){
                    $footer_top_col = 'col-sm-3';
                    ?>
                    <div id="footer-top">
                        <div class="footer-columns">
                            <?php if( is_active_sidebar( 'footer-col-one' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-one' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-two' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-two' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-three' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-three' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-four' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-four' ); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div><!-- #foter-top -->
                    <div class="clearfix"></div>
                    <?php
                }
                ?>
            </div><!-- bottom-->
            <?php if( isset( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ) ): ?>
                <p class="init-animate text-center animated fadeInLeft">
                    <?php echo wp_kses_post( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ); ?>
                </p>
            <?php endif;
             if ( 1 == $corporate_plus_customizer_all_values['corporate-plus-enable-social'] ) {
                    /**
                     * Social Sharing
                     * corporate_plus_action_social_links
                     * @since Corporate Plus 1.1.0
                     *
                     * @hooked corporate_plus_social_links -  10
                     */
                    do_action('corporate_plus_action_social_links');
                }
             ?>
            <div class="clearfix"></div>
            <div class="footer-copyright border text-center init-animate animated fadeInRight">
                <div class="site-info">
                    <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'corporate-plus' ) ); ?>"><?php printf( esc_html__( 'TEST %s', 'corporate-plus' ), 'WordPress' ); ?></a>
                    <span class="sep"> | </span>
                    <?php printf( esc_html__( 'Theme: %1$s by %2$s', 'corporate-plus' ), 'Corporate Plus', '<a href="http://www.acmethemes.com/" rel="designer"></a>' ); ?>
                </div><!-- .site-info -->
            </div>
            <a href="#page" class="sm-up-container"><i class="fa fa-arrow-circle-up sm-up"></i></a>
        </div>
    </footer>
    <?php
    }
endif;
add_action( 'corporate_plus_action_footer', 'corporate_plus_footer', 10 );

/**
 * Page end
 *
 * @since Corporate Plus 1.1.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_page_end' ) ) :

    function corporate_plus_page_end() {
        ?>
        </div><!-- #page -->
    <?php
    }
endif;
add_action( 'corporate_plus_action_after', 'corporate_plus_page_end', 10 );

I can change the above copyright info where it says TEST and this will update on my site. The problem is when I try and do this in my child theme so this doesn't get knocked out when the theme updates.

I have tried adding the acmethemes\hooks folders to the child theme and this did not work. I have also tried pasting the above PHP into my child themes functions.php file and then adding this into the footer.php which i also can't get working.

The footer.php file in the child theme is the below code. Which is also the same in the parent theme.

    <?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the #content div and all content after.
 *
 * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
 *
 * @package Acme Themes
 * @subpackage Corporate Plus
 */


/**
 * corporate_plus_action_after_content hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_after_content' );

/**
 * corporate_plus_action_before_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_before_footer' );

/**
 * corporate_plus_action_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked corporate_plus_footer - 10
 */
do_action( 'corporate_plus_action_footer' );

/**
 * corporate_plus_action_after_footer hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked null
 */
do_action( 'corporate_plus_action_after_footer' );

/**
 * corporate_plus_action_after hook
 * @since Corporate Plus 1.0.0
 *
 * @hooked corporate_plus_page_end - 10
 */
do_action( 'corporate_plus_action_after' );
wp_footer(); ?>
</body>
</html>

What I have noticed is in wp-content\themes\corporate-plus\acmethemes\hooks there is another footer.php file with the below code. I am not sure if I need to be doing anything with this.

    <?php
/**
 * Footer content
 *
 * @since Corporate Plus 1.0.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_footer' ) ) :

    function corporate_plus_footer() {

        global $corporate_plus_customizer_all_values;
        ?>
    <div class="clearfix"></div>
    <footer class="site-footer">
        <div class="container">
            <div class="bottom">
                <?php
                if(
                    is_active_sidebar('footer-col-one') ||
                    is_active_sidebar('footer-col-two') ||
                    is_active_sidebar('footer-col-three') ||
                    is_active_sidebar('footer-col-four')
                ){
                    $footer_top_col = 'col-sm-3';
                    ?>
                    <div id="footer-top">
                        <div class="footer-columns">
                            <?php if( is_active_sidebar( 'footer-col-one' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-one' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-two' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-two' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-three' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-three' ); ?>
                                </div>
                            <?php endif;
                            if( is_active_sidebar( 'footer-col-four' ) ) : ?>
                                <div class="footer-sidebar <?php echo esc_attr( $footer_top_col );?>">
                                    <?php dynamic_sidebar( 'footer-col-four' ); ?>
                                </div>
                            <?php endif; ?>
                        </div>
                    </div><!-- #foter-top -->
                    <div class="clearfix"></div>
                    <?php
                }
                ?>
            </div><!-- bottom-->
            <?php if( isset( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ) ): ?>
                <p class="init-animate text-center animated fadeInLeft">
                    <?php echo wp_kses_post( $corporate_plus_customizer_all_values['corporate-plus-footer-copyright'] ); ?>
                </p>
            <?php endif;
             if ( 1 == $corporate_plus_customizer_all_values['corporate-plus-enable-social'] ) {
                    /**
                     * Social Sharing
                     * corporate_plus_action_social_links
                     * @since Corporate Plus 1.1.0
                     *
                     * @hooked corporate_plus_social_links -  10
                     */
                    do_action('corporate_plus_action_social_links');
                }
             ?>
            <div class="clearfix"></div>
            <div class="footer-copyright border text-center init-animate animated fadeInRight">
                <div class="site-info">
                    <a href="<?php echo esc_url( __( 'https://wordpress.org/', 'corporate-plus' ) ); ?>"><?php printf( esc_html__( 'TEST %s', 'corporate-plus' ), 'WordPress' ); ?></a>
                    <span class="sep"> | </span>
                    <?php printf( esc_html__( 'Theme: %1$s by %2$s', 'corporate-plus' ), 'Corporate Plus', '<a href="http://www.acmethemes.com/" rel="designer"></a>' ); ?>
                </div><!-- .site-info -->
            </div>
            <a href="#page" class="sm-up-container"><i class="fa fa-arrow-circle-up sm-up"></i></a>
        </div>
    </footer>
    <?php
    }
endif;
add_action( 'corporate_plus_action_footer', 'corporate_plus_footer', 10 );

/**
 * Page end
 *
 * @since Corporate Plus 1.1.0
 *
 * @param null
 * @return null
 *
 */
if ( ! function_exists( 'corporate_plus_page_end' ) ) :

    function corporate_plus_page_end() {
        ?>
        </div><!-- #page -->
    <?php
    }
endif;
add_action( 'corporate_plus_action_after', 'corporate_plus_page_end', 10 );

I'm getting really confused now as I have tried adding the functions into my functions.php to try and override them and reference them in the footer.php with no luck.

Would someone be able to let me know where I am going wrong and what PHP i need to be adding where and I can give this another go.

Thanks in advance for any responses and help :)

closed as off-topic by Michael, Jacob Peattie, J.D., Howdy_McGee Dec 27 '18 at 22:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

3

Both functions check if the function corporate_plus_footer() exists. If not, one is defined. Without going deeper into hooks and filters, you can simply declare your own corporate_plus_footer() and the other won't get loaded.

Add this to your functions.php

function corporate_plus_footer() {
    echo 'it works';
}

No additional add_action() or similar. Just this function in your functions.php should already work.

  • Thanks for your reply, I will test this in a few minutes, if I add this, in which file location should I add my changes? Where should I now edit the copyright info? In the functions.php or where? – Harvey Dec 18 '18 at 18:35
  • your override function should do everything that the existing one does. you can add it in functions.php or any included/required file in your child theme. what you need to do is copy the entire function from the parent theme (minus the if exists) and then make your changes there. – mrben522 Dec 18 '18 at 18:41
  • I have tried adding function corporate_plus_footer() { echo 'it works'; } above the function corporate_plus_footer() { php but this isnt making the changes in the php below this. Am I missing something? – Harvey Dec 18 '18 at 20:33
  • not sure what I'm doing wrong here but I still can't get this to work... – Harvey Dec 18 '18 at 21:04
  • @Harvey Sorry, just got back. Have you already created a child theme that you're actively using? – kero Dec 19 '18 at 14:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.