how to put post title on a shortcode function
-
hi, I am creating a shortcode of a category of posts..
function pinterest_portfolio_shortcode($attr){ global $post; $postnum = 0; $catquery = new WP_Query( 'cat=40&showposts=1000' ); $retString = '<div class="portfolio-pinterest-wrapper"><div class="porfolio-pin-item portfolio-cat1"><div class="portfolio-header" style="width:100%;"><h2>'.get_cat_name(40).'</h2></div>'; while($catquery->have_posts()){ $catquery->the_post(); $full_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full', false); $retString .= '<div class="portfoliopin-item"><a href="'.$full_image[0].'" alt="" class="portfolio-image prettyphoto" rel="prettyPhoto[40]">'.get_the_post_thumbnail($post->ID, 'portfoliopin-item').'</a>'; $retString .= '<div class="portfoliopin-item-label"><h3 class="portfoliopin-title" style="font-size:14px">'.the_title().'</h3></div></div>'; } $retString .= '</div>'; $retString .= '</div>'; return $retString; } add_shortcode('pinterest_portfolio', 'pinterest_portfolio_shortcode');
but the
the_title()
in$retString .= '<div class="portfoliopin-item-label"><h3 class="portfoliopin-title" style="font-size:14px">'.the_title().'</h3></div></div>';
didn’t concatenate well, thethe_title()
returns before the html strings…thus anyone have an idea about my case? thanks in advance
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘how to put post title on a shortcode function’ is closed to new replies.