• 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

conditional $content_width /tiled galleries issue

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 › conditional $content_width /tiled galleries issue

This topic is: not resolved

Tagged: conditional logic, content width, jetpack, tiled galleries

  • This topic has 7 replies, 3 voices, and was last updated 12 years, 7 months ago by Brad Dalton.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • July 2, 2013 at 7:08 pm #48912
    jgk
    Member

    I'm using jetpack's tiled galleries.

    My content size may be from 1080px or 708px depending or whether there is a sidebar or not.

    In functions.php I have included the code:


    if ( ! isset( $content_width ) )
    $content_width = 1080;

    to solve the issue of the tiled galleries defaulting to 500 px width.

    My question is how to create a conditional tag to change the $content width depending on the page template or whether there is a sidebar. This post indicated it's not possible:

    http://wordpress.stackexchange.com/questions/6499/how-to-create-a-conditional-content-width-for-a-wordpress-theme

    but as indicated here the twentytwelve theme does just that:

    http://core.trac.wordpress.org/ticket/21256

    I haven't been able to alter this code to work in genesis which works in twentytwelve:

    if ( ! isset( $content_width ) )
    $content_width = 625;

    function twentytwelve_content_width() {
    if ( is_page_template( 'full-width-page.php' ) || is_attachment() ) {
    global $content_width;
    $content_width = 960;
    }
    }
    add_action( 'template_redirect', 'twentytwelve_content_width' );

    Then I tried setting the default content width in functions.php and setting a different content width in different pages, but it just broke the page:

    $content_width=910;

    on this page:

    http://jgtest.wpengine.com/blog/

    the tiled galleries are showing up properly at the top and then as you scroll down the page they are going full width and still expanding into the sidebar.

    Any thoughts on setting a conditional $content_width's?

    Thanks in advance.

    http://jgtest.wpengine.com/blog/
    July 3, 2013 at 12:43 am #48932
    Brad Dalton
    Participant

    Might be right about that but this code will change the media embed size conditionally:


    Tutorials for StudioPress Themes.

    July 29, 2013 at 2:29 pm #53104
    Kary
    Member

    Hi Brad,
    I'm not 100% if what I'm supposed to do I actually did correctly. But I'm have a similar issue with the Jetpack tiled gallery displaying full width on a page. I have selected the "full width" page (no sidebars) in the page's layout. And copied/pasted the code you have above in my functions file. I increased the width to 1000 just to see if anything would happen. It did not resolve the problem.

    I have tried both "random" layouts and chronological order but that didn't help the actual width of the gallery either...just the order in which the thumbnails appear. You can see the page I'm talking about below. Do you have any more suggestions as to how to fix this?
    Thanks.
    http://www.unstuckification.com/artwork/

    July 29, 2013 at 6:45 pm #53145
    Brad Dalton
    Participant

    The above code snippet is an example only and needs to be modified according to your own specific needs.

    The template name in included is a demo template name. You will need to change this by finding the template name in your source code or using a page i.d rather than template name in the conditional statement.


    Tutorials for StudioPress Themes.

    July 29, 2013 at 8:35 pm #53158
    Kary
    Member

    Thanks again, but still not working. I changed
    is_page_template( 'full-width-content.php' ) to
    is_page( 719 ) -- 719 is the page id for that specific page.

    I loaded the Twenty-twelve theme and the gallery will go to full page. And as you can see, the text goes to full page. It is only the gallery tiles that do not. So I'm starting to think that there is something about the Genesis themes that isn't compatible with Jetpack's tiled gallery. Which is a bummer.

    July 29, 2013 at 9:09 pm #53166
    Brad Dalton
    Participant

    This is what i used for a single post and it works:

    This is what i used for a static page and it works:

    The problem is with the conditional tag rather than with Genesis which is 100% WordPress compatible and developed running bleeding nightlies (latest daily WordPress development version).

    is_page only works for pages
    is_single only works for posts
    

    Tutorials for StudioPress Themes.

    July 29, 2013 at 9:56 pm #53171
    Kary
    Member

    Thank you Brad! That last code worked just fine. I'm using the "is_page" option as before. But now its working just as it did in the default theme. This is awesome because I've been looking all over the web. So many people are having issues with the tiled gallery (not just in Studio Press). You're a genius. 🙂

    July 29, 2013 at 10:38 pm #53174
    Brad Dalton
    Participant

    No worries Kary.

    Just published a post on it also.


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 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