Skip to content

Instantly share code, notes, and snippets.

@jrstaatsiii
Created July 2, 2012 20:56
Show Gist options
  • Save jrstaatsiii/3035661 to your computer and use it in GitHub Desktop.
Save jrstaatsiii/3035661 to your computer and use it in GitHub Desktop.
Featured Checkbox using WPAlchemy
// 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