Reputation: 1711
I have the following code in an Wordpress template file (Goodwork theme) which outputs a list of posts.
$args = array( 'posts_per_page' => $v_filter == 'true' ? -1 : 12,
'offset'=> 0,
'paged' => $paged,
'portfolio_category' => $custom_cat,
'post_type' => 'portfolio');
$all_posts = new WP_Query($args);
The bit I'm having trouble with is $custom_cat
which is set further above in the template like so:
$v_cats = get_post_meta($post->ID, 'rb_meta_box_portfolio_set', true);
$all_cats = !empty($v_cats) ? implode($v_cats, ', ') : -1;
$custom_cat = isset($_GET['f']) ? $_GET['f'] : $all_cats;
The problem is that it's ignoring posts from a certain category.
If I change the code to $custom_cat = 'promotions'
which is the name of the category not showing, then it outputs posts from that category, but not when pulling all categories.
Anyone have an idea why that might be?
In answer to BIOSTALL's question, the only other place that rb_meta_box_portfolio_set
is referenced is in metaboxes.php where it's setting the Portfolio Post Type:
$rb_meta_box_portfolio = array(
'id' => 'rb_meta_box_portfolio',
'title' => 'Portfolio Options',
'desc' => '',
'pages' => array( 'page' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'id' => 'rb_meta_box_portfolio_set',
'label' => 'Choose categories',
'desc' => 'Select the categories which will appear in this portfolio.',
'std' => 'portfolio',
'type' => 'checkbox',
'class' => '',
'choices' => $portfolios_array
),
Upvotes: 1
Views: 85
Reputation: 1242
Implode takes string first and then array, please check php.net official documentation. Please change your implode
as following:
implode(', ', $v_cats)
thanks.
Upvotes: 1