• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Page Template Widget Disappeared

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Page Template Widget Disappeared

This topic is: not resolved

Tagged: mobile widgets, Page Templates, widgets

  • This topic has 1 reply, 1 voice, and was last updated 10 years, 6 months ago by LeaChristine.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 28, 2015 at 7:34 am #160733
    LeaChristine
    Member

    Hi all- so I've created a widget for a site that I'm working on, and I need to have it display only on the home/landing page, and only on mobile-sized screens. I had the widget up and working, but for some reason it has disappeared? I haven't changed any of the coding for it, so I'm not sure what happened... Here is the code I have for my functions.php:

    <?php
    //* Start the engine
    include_once( get_template_directory() . '/lib/init.php' );
    
    //* Child theme (do not remove)
    define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
    define( 'CHILD_THEME_VERSION', '2.1.2' );
    
    //* Enqueue Google Fonts
    add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
    function genesis_sample_google_fonts() {
    
    	wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700', array(), CHILD_THEME_VERSION );
    
    }
    
    //* Add HTML5 markup structure
    add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
    
    //* Add viewport meta tag for mobile browsers
    add_theme_support( 'genesis-responsive-viewport' );
    
    //* Add support for custom background
    add_theme_support( 'custom-background' );
    
    //* Add support for 3-column footer widgets
    add_theme_support( 'genesis-footer-widgets', 3 );
    
    //* Add function for header image
    function sample_header_image() {
        ?>
        <div class="header-image">
            <a href="http://www.sample.leachristinedesigns.com/"><img src="http://sample.leachristinedesigns.com/wp-content/uploads/2015/06/Logo-BLACK-cropped.png" /></a>
        </div>
        <?php
    	
    }
    add_action( 'genesis_header', 'sample_header_image' );
    
    //* Register widget for HOURS
    genesis_register_sidebar( array(
    	'id'          => 'hours',
    	'name'        => __( 'Hours' ),
    	'description' => __( 'This is the area where hours are displayed' ),
    ) );
    
    //* Hook social widget area in header
    add_action( 'genesis_header', 'hours', 4);
    function hours() {
     
    	genesis_widget_area( 'hours', array(
    		'before' => '<div class="hours">',
    		'after'  => '</div>',
    	) );
     
    }
    
    //* Register widget for ADDRESS
    genesis_register_sidebar( array(
    	'id'          => 'address',
    	'name'        => __( 'Address' ),
    	'description' => __( 'This is the area where address, phone, and social are displayed' ),
    ) );
    
    //* Hook social widget area in header
    add_action( 'genesis_header', 'address', 4);
    function address() {
     
    	genesis_widget_area( 'address', array(
    		'before' => '<div class="address">',
    		'after'  => '</div>',
    	) );
     
    }
    
    //* Register widget for MOBILE CONTACT WIDGET
    genesis_register_sidebar( array(
    	'id'          => 'mobile-widget',
    	'name'        => __( 'Mobile Widget' ),
    	'description' => __( 'This is the area where phone and map links are displayed on mobile screen sizes' ),
    ) );
    
    //* Hook social widget area in header
    add_action( 'genesis_header', 'mobilewidget');
    function mobilewidget() {
    
    // If it's the Landing page, display slider
    
    if ( is_front_page() && is_home() ) {
     
    	genesis_widget_area( 'mobile-widget', array(
    		'before' => '<div class="mobile-widget">',
    		'after'  => '</div>',
    	) );
     
    }
    
    }
    
    //* Register widget for SLIDER
    genesis_register_sidebar( array(
    	'id'          => 'slider',
    	'name'        => __( 'Slider Area' ),
    	'description' => __( 'This is the area where the slider is displayed' ),
    ) );
    
    //* Hook social widget area in header
    add_action( 'genesis_before_content', 'slider');
    function slider() {
    
    // If it's the About page, display slider
    
    if (is_page( 'about' ) ) {
     
    	genesis_widget_area( 'slider', array(
    		'before' => '<div class="slider">',
    		'after'  => '</div>',
    	) );
     
    }
    
    }

    The HTML I have in the widget itself is:

    <div class="mobile-call">
    <a href="tel:585-222-2222"><img src="http://sample.leachristinedesigns.com/wp-content/uploads/2015/07/CALL.png" width="90px"></a>
    </div>
    
    <div class="mobile-find">
    <a href="https://goo.gl/maps/RhqEe"><img src="http://sample.leachristinedesigns.com/wp-content/uploads/2015/07/FIND.png" width="90px"></a>
    </div>

    And then here is the css I have in order to display the widget only on mobile screen-size:

    /* # Hide Mobile Widget
    ----------------------------------------- */
    
    .mobile-widget {
    display: none;
    }
    
    @media only screen and (max-width: 450px) {
    
    /* # Mobile Widget
    ----------------------------------------- */
    
    .mobile-widget {
    display: inline-block !important;
    padding-top: 20px;
    width: 100%;
    }
    
    .mobile-call {
    float: left;
    padding-left: 20px;
    }
    
    .mobile-find {
    float: right;
    padding-right: 20px;
    }
    }
    http://sample.leachristinedesigns.com/
    July 28, 2015 at 7:47 am #160736
    LeaChristine
    Member

    I figured it out, thanks.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble