Skip to content

Instantly share code, notes, and snippets.

@cpaul007
Last active August 29, 2015 14:23
Show Gist options
  • Save cpaul007/579f80130ebe25bfad36 to your computer and use it in GitHub Desktop.
Save cpaul007/579f80130ebe25bfad36 to your computer and use it in GitHub Desktop.
Adding Categories and Tags into Pages
<?php //* Do not include this opening tags
//* All codes will go to functions.php file
/**
* Displaying categories and tags at bottom of the pages
*
* @author Genesis Developer
* @link http://genesisdeveloper.me
* @since 1.0
* @version 1.0
**/
/** Enabling Categories and Tags options for pages
*
* @since 1.0
*
*/
add_action('init', 'gd_register_category_tags_taxonomy_for_page');
function gd_register_category_tags_taxonomy_for_page() {
register_taxonomy_for_object_type('post_tag', 'page');
register_taxonomy_for_object_type('category', 'page');
}
add_filter( 'genesis_page_meta', 'do_shortcode', 20 );
add_action( 'genesis_entry_footer', 'genesis_page_entry_footer_markup_open', 5 );
add_action( 'genesis_entry_footer', 'genesis_page_entry_footer_markup_close', 15 );
add_action( 'genesis_entry_footer', 'genesis_page_meta' );
/**
* Echo the opening structural markup for the entry footer.
*
* @since 2.0.0
*
* @uses genesis_attr() Contextual attributes.
*/
function genesis_page_entry_footer_markup_open() {
if ( 'page' === get_post_type() )
printf( '<footer %s>', genesis_attr( 'entry-footer' ) );
}
/**
* Echo the closing structural markup for the entry footer.
*
* @since 2.0.0
*/
function genesis_page_entry_footer_markup_close() {
if ( 'page' === get_post_type() )
echo '</footer>';
}
/**
* Echo the page meta after the page content.
*
* The page info makes use of a couple of shortcodes by default, and
* the whole output is filtered via 'genesis_page_meta' before echoing.
*
* @since 1.0.0
*
* @uses genesis_markup() Contextual markup.
*
* @return null Return early if on a post
*/
function genesis_page_meta() {
if ( 'post' === get_post_type() )
return;
$output = genesis_markup( array(
'html5' => '<p %s>',
'xhtml' => '<div class="post-meta">',
'context' => 'entry-meta-after-content',
'echo' => false,
) );
$output .= apply_filters( 'genesis_page_meta', '[post_categories] [post_tags]' );
$output .= genesis_html5() ? '</p>' : '</div>';
echo $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment