List of all posts from current category on single portfolio page


Im using the wordpress theme bridge and the portfolio with different categories. I edit the portfolio-loop to get a list of all items of the current category.

I found the following code here and tried to change it the way I need.


$args = array(
    'post_type'      => 'portfolio_page',
    'post_status'    => 'publish',
    'orderby'        => 'date',
    'order'          => 'DESC',
    'portfolio_category' => get_query_var( 'portfolio_category' )

$my_query = new WP_Query( $args );

if ( $my_query->have_posts() ) {

    echo '<ul>';

    while ( $my_query->have_posts() ) {

        echo '<li><a href="' . get_permalink( $post -> ID ) . '">' . get_the_title() . '</a></li>';


    echo '</ul>';



But I get the complete of every portfolio from every category. The following part is not working.

'portfolio_category' => get_query_var( 'portfolio_category' )

It works, when Im adding a certain category like this:

'portfolio_category' => 'category-a'

Whats wrong? Thanks

Ingo Lembke 4 years 2020-05-25T05:10:32-05:00 0 Answers 76 views 0

Leave an answer