0

I need help with this as it's my first project of my new job & I'm stuck at this point.

I'm retrieving custom post types portfolio using this code as a shortlist:

extract( shortcode_atts( array( 'limit' => -1, 'type' => 'post'), $atts ) );

$paged = get_query_var('paged') ? get_query_var('paged') : 1;  

query_posts(  array ( 
    'posts_per_page' => $limit, 
    'post_type' => $type, 
    'order' => 'ASC', 
    'orderby' =>'menu_order', 
    'paged' => $paged ) );

$list = ' ';   

while ( have_posts() ) { the_post();

    $list .= '<li class="mix all">' 
    . '<div class="listing-content">' 
    . '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>' 
    .'<p>' . get_the_excerpt() . '</p>'
    . '<a href="' . get_permalink() . '">' . 'View &raquo;' . '</a>'
    . '</div>'
    . '<a class="listing-thumb" href="' . get_permalink() . '">' . get_the_post_thumbnail($page->ID, 'listing-thumb')  . '<span></span></a>'
    . '</article>';
}

return 
'<div class="listings clearfix">' 
. $list 
. '<div class="nav-previous">' . get_next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts' ) ) . '</div>'
. '<div class="nav-next">' . get_previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>' ) ) . '</div>'
. '</div>' .
wp_reset_query();

}
add_shortcode( 'feed', 'section_feed_shortcode' );

I want to display the custom taxonomy "name" at the following point of code:

$list .= '<li class="mix all ####RIGHT HERE#### ">' 

Is it possible to do. If yes, then featured image as well.

Thanks!

  • Taxonomy or terms assigned to given post? What is the taxonomy name? – Krzysiek Dróżdż Apr 23 '14 at 17:44
  • Terms assigned to given post. – Hardeep Asrani Apr 23 '14 at 17:49
  • port_tags is the taxonomy name. – Hardeep Asrani Apr 23 '14 at 17:53
1

OK, so you have to modify some part of your code like so:

$list = ' ';

while ( have_posts() ) {
    the_post();

    $terms = get_the_terms( $post->ID, 'port_tags' );
    $terms_string = '';
    if ( $terms ) {
        foreach ( $terms as $term )
            $terms_string .= $term->slug . ' ';
    }

    $list .= '<li class="mix all '. $terms_string .'">' 
    . '<div class="listing-content">' 
    . '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>' 
    .'<p>' . get_the_excerpt() . '</p>'
    . '<a href="' . get_permalink() . '">' . 'View &raquo;' . '</a>'
    . '</div>'
    . '<a class="listing-thumb" href="' . get_permalink() . '">' . get_the_post_thumbnail($page->ID, 'listing-thumb')  . '<span></span></a>'
    . '</article>';  // <- it should be </li> not </article>, I guess - you don't open any <article> tag in this loop
}
| improve this answer | |
  • No problem, Hardeep :) – Krzysiek Dróżdż Apr 23 '14 at 18:15
  • How to retrieve featured image of this custom post type? – Hardeep Asrani Apr 23 '14 at 18:36
  • Use the_post_thumbnail function. – Krzysiek Dróżdż Apr 23 '14 at 18:57
  • I have tried to use it, but it's working everywhere but in this code. – Hardeep Asrani Apr 23 '14 at 19:09
  • Could you show your code? How have you tried to use this function? – Krzysiek Dróżdż Apr 23 '14 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.