jeudi 16 avril 2015

How to retrive Category name from menu

Hello i have some complex theme , i have some other custom pages for specific category list because i need to list them different :



<?php if ( have_posts() ) : ?>

<div id="blog-grid" class="row content-grid">
<?php
query_posts('category_name=catname1&showposts=20');
while ( have_posts() ) : the_post();
?>
<div class="<?php echo esc_attr( tdmacro_column_class() ); ?> post-box">
<?php get_template_part( 'content', get_post_format() ); ?>
</div><!-- .col -->
<?php endwhile; ?>
</div><!-- .row -->

<?php tdmacro_paging_nav(); ?>

<?php else : ?>

<?php get_template_part( 'content', 'none' ); ?>

<?php endif; ?>


You can see this line :



query_posts('category_name=catname1&showposts=20');


which i using to take the specific category post name lists.


Now lets see i put subpage under catname1 with the same custom template and call him catname2, i want to pull from menu when i press catname2 and list all posts from catname2 it's possible ?


i mean to change this query_posts('category_name=catname1&showposts=20'); by specific cat name each time on change .


Now it's not dynamic it's only show catname1 posts .


I try :



$cat_mame = get_cat_name( $currentcatID ) ;


and more method from google/wordpress codex but didn't get it to work, thanks.


Aucun commentaire:

Enregistrer un commentaire