Created
October 18, 2012 11:01
-
-
Save manishsongirkar/3911036 to your computer and use it in GitHub Desktop.
Add Wordpress Category list in pages as shown in posts
This file contains 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
function create_page_taxonomy() { | |
register_taxonomy( 'category', array( 'page', 'post' ), array( | |
'hierarchical' => true, | |
'label' => __( 'Categories' ), | |
'singular_label' => __( 'Category' ), | |
'show_ui' => true, | |
'query_var' => true, | |
'rewrite' => true | |
) ); | |
} | |
add_action( 'init', 'create_page_taxonomy' ); |
This file contains 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
$the_query = new WP_Query( array( | |
'post_type' => 'page', | |
'category_name'=> 'catname' | |
) ); | |
echo '<ul class="custom-class">'; | |
// The Loop | |
while ( $the_query->have_posts() ) : $the_query->the_post(); | |
echo '<li>'; | |
echo '<a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a>'; | |
echo '</li>'; | |
endwhile; | |
echo '</ul>'; | |
// Reset Post Data | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment