[Resolved] Removing Footer and Copyright on Mobile Via PHP in Child Theme

Home Forums Support Removing Footer and Copyright on Mobile Via PHP in Child Theme

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1376962
    Andres

    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

    #1376991
    Leo
    Staff
    Customer Support

    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 );
        }
    } );
    #1377006
    Andres

    Hi Leo,

    That did it!

    Thank you, and enjoy the rest of your weekend.

    Cheers!

    Andrés

    #1377030
    Leo
    Staff
    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.