Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using a widget, U more recent posts. Seems to work with custom taxonomies when you input the correct data into it in a widget form, but the suggested shortcode doesn't work (and I am trying to insert it into a post).

He suggests including the following;

tax_query="taxonomy=category&terms=14,17"

so I have tried....

[u_more_recent_posts id="hue-recent-posts" tax_query="taxonomy=destinations&terms=174" post_type="post"]

I am sure, I just need to alter the shortcode slightly for it to work, but have been trying for hours and can't work it out!! Any help would be ENORMOUSLY appreciated!!

I think the relevant code in the plugin are;

if( !empty($opts['post_type']) ) {
    $query_args['post_type'] = $opts['post_type'];

    if( !empty($opts['tax_query']) AND isset($opts['tax_query'][$opts['post_type']]) ) {
        $tax_query = $opts['tax_query'][$opts['post_type']];

        if( !empty($tax_query['taxonomy']) AND !empty($tax_query['terms']) ){
            $tax_query['terms'] = explode(',', preg_replace('/\s*/', '', $tax_query['terms']));
            $_tax_query = array(
                'taxonomy' => $tax_query['taxonomy'],
                'terms' => $tax_query['terms'],
                'field' => 'id',
            );
            $operator = '';
            switch($tax_query['operate']){
                case 'include': $operator = 'IN'; break;
                case 'exclude': $operator = 'NOT IN'; break;
                case 'and': $operator = 'AND'; break;
            }
            if( !empty($operator) )
                $_tax_query['operator'] = $operator;

            $query_args['tax_query'] = array($_tax_query);
        }
    }
}

and this bit.....

if( isset($atts['tax_query']) ){
    $opts['tax_query'] = array($opts['post_type'] => wp_parse_args(preg_replace('/&/', '&', $atts['tax_query'])));
}

Thanks very much in advance, I am completely stuck!!

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.