Last active
September 29, 2015 09:37
-
-
Save flayder/71034bfb4b4cf306ea49 to your computer and use it in GitHub Desktop.
Вывод подкатегорий и записей из родительской категории!
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
<?php | |
function productCart() { | |
?> | |
<div class="buy-with"> | |
<h2><?php echo get_cat_name(46); ?></h2> | |
<ul> | |
<?php | |
$parent_id = 46; | |
$sub_cats = get_categories( array( | |
'child_of' => $parent_id | |
) ); | |
if( $sub_cats ){ | |
foreach( $sub_cats as $cat ){ | |
$posts = get_posts( array( | |
'numberposts' => -1, | |
'category' => $cat->cat_ID | |
) ); | |
global $post; | |
foreach($posts as $post){ setup_postdata($post); ?> | |
<div class="img"><?php the_post_thumbnail(); ?> </div> | |
<a href="<?php get_permalink();?>"><?php the_title();?></a> | |
<?php | |
} | |
wp_reset_postdata(); | |
} | |
} | |
?> | |
</ul> | |
</div> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment