Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Show posts from that are in category1 AND category2

$
0
0

Replies: 0

Hello,

Great plugin… I have been playing around with code from the paid support forum to dynamically show posts from the same category. This code works great!

<?php if ( is_single() ) {
$cats = get_the_category();
$cat = $cats[0];
} else {
$cat = get_category( get_query_var( ‘cat’ ) );
}

$cat_slug = $cat->slug;

wpsp_display( 503224, ‘tax_term=”‘ . $cat_slug . ‘”‘ ); ?>

What I would like to do is if I have a post in more than one category that I can have the plugin display other posts that are in both categories. If a post is in category1 and category2 then show other posts that are in category1 AND category2.

<?php if ( is_single() ) {
$cats = get_the_category();
$cat0 = $cats[0];
$cat1 = $cats[1];
} else {
$cat0 = get_category( get_query_var( ‘cat’ ) );
}

$cat0_slug = $cat0->slug;
$cat1_slug = $cat1->slug;

wpsp_display( 503224, ‘tax_term=”‘ . $cat0_slug . ‘”‘ && ‘tax_term=”‘ . $cat1_slug . ‘”‘); ?>

Here is one of my attemts that is not working, thanks for the help.

If I can get this to work then I will be buying the developer version since I am running multiple sites.

Take care,
Garrett


Viewing all articles
Browse latest Browse all 59525

Trending Articles