• I want count my posts by multyple slugs/slug, where post have – all slugs exemple (slug1, slug2, slug3 ), i tried with

    $terms = get_terms(“adstags” , “slug=slug1&slug=slug2&slug=slug3”);
    $count = count($terms); – is wrong….

    I found some code
    $myquery = array(
    array(
    ‘taxonomy’ => ‘adstags’,
    ‘terms’ => array(‘slug1’),
    ‘field’ => ‘slug’,
    ),
    array(
    ‘taxonomy’ => ‘adstags’,
    ‘terms’ => array(‘slug2’),
    ‘field’ => ‘slug’,
    ),
    );

    I do not know how to implement get_terms

Viewing 1 replies (of 1 total)
  • Thread Starter xdynx

    (@xdynx)

    DONE
    // $tags = “slu1,slug2”;
    function countposttags($tags) {
    global $wpdb;

    $tags = explode(“,”, $tags);

    $myquery[‘tax_query’] = array();

    foreach ($tags as $tag) {

    array_push($myquery[‘tax_query’], array(
    ‘taxonomy’ => ‘adstags’,
    ‘terms’ => array($tag),
    ‘field’ => ‘slug’,
    ));
    } // end forech

    $a = query_posts($myquery);
    return sizeof($a);

    }

Viewing 1 replies (of 1 total)
  • The topic ‘Count posts by slug’ is closed to new replies.