Last active
October 2, 2016 12:51
-
-
Save michaelvandenberg/004898e4a5e4aaf00147be07b3e2d9d2 to your computer and use it in GitHub Desktop.
Set the content width in pixels and adjust the content width for full width pages.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set the content width in pixels, based on the theme's design and stylesheet. | |
* | |
* Priority 0 to make it available to lower priority callbacks. | |
* | |
* @global int $content_width | |
*/ | |
function bookmark_content_width() { | |
$GLOBALS['content_width'] = apply_filters( 'bookmark_content_width', 800 ); | |
} | |
add_action( 'after_setup_theme', 'bookmark_content_width', 0 ); | |
/** | |
* Adjust content_width value for full width page template. | |
*/ | |
function bookmark_full_width_page_content_width() { | |
if ( is_page_template( 'page-templates/template-full-width.php' ) ) { | |
$GLOBALS['content_width'] = apply_filters( 'bookmark_full_width_page_content_width', 1280 ); | |
} | |
} | |
add_action( 'template_redirect', 'bookmark_full_width_page_content_width' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See list of action hooks: https://codex.wordpress.org/Plugin_API/Action_Reference
Content width for the full width page can't be adjusted before "parse_query" or after "the_post".