How to get the post of category

<?php // Get the ID of a given category $category_id = get_cat_ID( ‘Category Name’ ); // Get the URL of this category $category_link = get_category_link( $category_id ); ?> <!– Print a link to this category –> <a href=”https://wordpress.stackexchange.com/questions/94519/<?php echo esc_url( $category_link ); ?>” title=”Category Name”>Category Name</a> After you click on the Category Title link, it … Read more

How to add the sidebar in all category page

the following code will work as for per your custom post type add the following code in sidebar.php to show your custom post type category <?php //list terms in a given taxonomy using wp_list_categories (also useful as a widget) $orderby = ‘name’; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; … Read more

Recent posts in current category?

Here’s how I’d get the 20 (at most) most recent posts in the category.php page: <?php $max_posts = 20; $cat_ID = get_cat_ID ( single_cat_title( ”, false ) ); $args = array( ‘category’ => $cat_ID, ‘numberposts’ => $max_posts, ); $myposts = get_posts( $args ); foreach( $myposts as $post ) { setup_postdata( $post ); ?> <!– add … Read more

Make three menus with three category levels

wp_list_categories(); will by default give you a hierarchically nested list of all your categories. Hiding and showing that list, or parts of it, is just a matter of CSS. That sounds like what you need. For example echo ‘<ul class=”my-cats-list”>’,wp_list_categories(),'</ul>’; // style rules; put in your theme’s style.css .cat-item { padding-left:5px; } .children { display:none; … Read more