Community Forums › Forums › Archived Forums › Design Tips and Tricks › conditional $content_width /tiled galleries issue
Tagged: conditional logic, content width, jetpack, tiled galleries
- This topic has 7 replies, 3 voices, and was last updated 11 years, 4 months ago by Brad Dalton.
-
AuthorPosts
-
July 2, 2013 at 7:08 pm #48912jgkMember
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:
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 #48932Brad DaltonParticipantMight be right about that but this code will change the media embed size conditionally:
July 29, 2013 at 2:29 pm #53104KaryMemberHi 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 #53145Brad DaltonParticipantThe 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.
July 29, 2013 at 8:35 pm #53158KaryMemberThanks 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 #53166Brad DaltonParticipantThis 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
July 29, 2013 at 9:56 pm #53171KaryMemberThank 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 #53174Brad DaltonParticipant -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.