Created
July 2, 2012 20:56
-
-
Save jrstaatsiii/3035661 to your computer and use it in GitHub Desktop.
Featured Checkbox using WPAlchemy
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
// in metaboxes.php | |
// Featured Portfolio Metabox | |
<?php | |
$featured_portfolio_mb = new WPAlchemy_MetaBox(array | |
( | |
'id' => '_ssm_featured_meta', | |
'title' => 'Featured Portfolio Item', | |
'template' => SSM_DIR . '/lib/functions/wpalchemy/custom/featured_meta.php', | |
'context' => 'side', | |
'autosave' => TRUE, | |
'types' => array('portfolio','post'), | |
'priority' => 'high', | |
'save_action' => 'pull_featured_data' | |
)); | |
function pull_featured_data($meta, $post_id) { | |
update_post_meta( $post_id, '_ssm_featured_post', $meta['featured'] ); | |
} | |
?> | |
//In home.php -- the WP_Query $args | |
<?php | |
$args = array( | |
'post_type' => array('post','portfolio'), | |
'meta_key' => '_ssm_featured_post', | |
'meta_value' => '1', | |
'posts_per_page' => -1 | |
); | |
?> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment