Site logo

Archived topic

Removing Footer and Copyright on Mobile Via PHP in Child Theme

3 replies · Started by Andres on July 26, 2020

Viewing posts 1–4 of 4

Hello,

Recently, I tried using the PHP code provided by you guys to remove the footer and copyright area on mobile and it did not work. I inserted the code in the functions.php file in the child theme.

Could you please review the code below and let me know if it is correct and if I input it in the correct location and in the correct place in the functions.php file? Note: I am providing all the code in the functions.php file for reference. The first line of the code in question is "add_action( 'wp', function() {". I did restart the server after uploading the code.

<?php
/**
 * GeneratePress child theme functions and definitions.
 *
 * Add your custom PHP in this file. 
 * Only edit this file if you have direct access to it on your server (to fix errors if they happen).
 */

function generatepress_child_enqueue_scripts() {
	if ( is_rtl() ) {
		wp_enqueue_style( 'generatepress-rtl', trailingslashit( get_template_directory_uri() ) . 'rtl.css' );
	}
}
add_action( 'wp_enqueue_scripts', 'generatepress_child_enqueue_scripts', 100 );

add_action( 'wp', function() {
    if ( wp_is_mobile() && is_user_logged_in() ) {
        remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
        remove_action( 'generate_footer', 'generate_construct_footer', 10 );
    }
} );

Thank you and have a good day!

Andrés

Hi there,

Can you try this instead?

add_action( 'wp', function() {
    if ( wp_is_mobile() ) {
        remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
        remove_action( 'generate_footer', 'generate_construct_footer', 10 );
    }
} );

Hi Leo,

That did it!

Thank you, and enjoy the rest of your weekend.

Cheers!

Andrés

No problem :)

This archived topic is closed to new replies.