theme-development

Codes for theme modification, alteration, removing bugs etc.

  • Remove emoji script from WordPress Header

    ·

    // Disable the emoji's Scripts from WordPress Head
    remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
    remove_action( 'wp_print_styles', 'print_emoji_styles' );
  • Make WordPress Admin Bar Invisible

    ·

    Add the following code inside functions.php

    add_filter( 'show_admin_bar', '__return_false' );

    The above code will hide admin bar for all users including administrators. If you like show admin bar to admins only, then add the following code:-

    add_action('after_setup_theme', 'remove_admin_bar');
    function remove_admin_bar() {
    if (!current_user_can('administrator') && !is_admin()) {
      show_admin_bar(false);
    }
    }
  • Add the following code inside the functions.php file of the theme.

    add_filter( 'login_redirect', function ( $redirect_to, $requested_redirect_to ) {
    if ( ! $requested_redirect_to ) {
    $redirect_to = wp_get_referer();
    }
    return $redirect_to;
    }, 10, 2 );
    
  • How to Increase Font Size of bbPress

    ·

    Add the following code snippet in your theme style.css

    /* bbpress specific styling */
    
    #bbpress-forums,
    #bbpress-forums ul.bbp-forums,
    #bbpress-forums ul.bbp-lead-topic,
    #bbpress-forums ul.bbp-replies,
    #bbpress-forums ul.bbp-search-results,
    #bbpress-forums ul.bbp-topics,
    div.bbp-template-notice li,
    div.bbp-template-notice p,
    div.bbp-breadcrumb,
    div.bbp-topic-tags {
    	font-size: .9rem;
    	line-height: 1.5;
    }
    
    #bbpress-forums .bbp-forum-info .bbp-forum-content,
    #bbpress-forums p.bbp-topic-meta,
    span.bbp-admin-links a {
    	font-size: .9rem;
    }
    
  • Add Login / Logout Link at the Footer of your WordPress powered Website

    Here in this example we used GeneratePress theme.

    Site Footer Before Customization:

    Site Footer After Customization:

    Edit the footer.php file
    (For GeneratePress theme the path is /wp-content/themes/generatepress/inc/structure/footer.php)

    Before:

    After:

  • Add Widgets in Front Page of Genesis Theme

    ·

    We have earlier shared “How to Add Widgets to Homepage of Genesis theme“. Now we are sharing a similar guide, “how to add widgets in frontpage of any genesis theme” so that it become a magazine theme.

    There are three steps as usual.

    Step 1: To add code in functions.php
    Step 2: To create a front-page.php file
    Step 3: To add code in style.css

    Step 1: Add the following code into functions.php

    Step 2: Create front-page.php

    Step 3: Add the following codes into style.css

    Inside the media query of style.css add the following code:

    That’s it. Now you will get a magazine style homepage as follows:

    front-page