Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Function inside "do_shortcode"

Hey guys...

I need to put this

<?php if (is_category( )) { $cat = get_query_var("cat"); $yourcat = get_category ($cat); echo $yourcat->slug; } ?>

instead of FUNCTIONHERE in this code:

<?php echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="3" max_pages="0" button_label="Load More" category="FUNCTIONHERE"]'); ?>

I tried so many variations but nothing seem to work, could you please help me figure this out?

1 Answer

Sorry for bugging you all... I found solution as soon as I posted here...

In case anyone is interested, solution is this

<?php
$cat = get_category( get_query_var( 'cat' ) );
$category = $cat->slug;
echo do_shortcode('[ajax_load_more post_type="post" posts_per_page="3" max_pages="0" button_label="Load More" category="'.$category.'"]');
?>