I am trying to puzzle out why my shortcode is not working - can anybody understand why (apologies for crappy formatting, can't appear to obtain this shortcode to show correctly)?

The code is running above my shortcode for whatever reason. Unsure I completely learn how to use template tags /Wordpress functions in shortcodes when i believe you should utilize something similar to get_ at the outset of the function to be able to give it back inside a variable within shortcodes. Can anybody help?



/* News from Blog category only - category 3 */

add_shortcode( 'latestblogposts', 'osu_latestblogposts' );

function osu_latestblogposts() {
    $start = '<div class="widget widget_osu_blog">';
    $start .= '<a title="Subscribe to our RSS feed" href="/feed?cat=3" class="rss"><img alt="RSS" src="' . get_bloginfo('template_directory') . '/images/ico-rss-big.png"></a>';
    $start .= '<div>';

    $my_query = new WP_Query('category=3&showposts=3');
    while ($my_query->have_posts()) : $my_query->the_post();
        $inner = '<div class="item"><a href="' . get_permalink() . '" title="';
        $inner .= printf( esc_attr__( 'Permalink to %s', 'inspire' ), the_title_attribute( 'echo=0' ) );
        $inner .= '" rel="bookmark" class="title">' . the_title() . '</a>';
        $inner .= '<p class="post-meta">';
        $inner .= '<span class="small">by</span> <span class="post-author"><a title="Posts by ';
        $inner .= the_author();
        $inner .= '" href="' . the_author_posts_link() . '">' . the_author() . '</a></span>';
        $inner .= '<span class="small">on</span> <span class="post-date">';
        $inner .= get_the_date('d/m/Y') . '</span></p>';
        $inner .= the_excerpt() . '</div> <!-- End div.item -->';

    $end = '</div>';
    $end .= '</div> <!-- End div.widget_osu_blog -->';

    $latestblogposts = $start . $inner . $end;
    return $latestblogposts;

Basically understand you properly, you have to call the functions by having an optional argument to be able to obtain the came back value rather than echo it directly. For example, using the_title(), you've 3 optional arguments, the 3rd sets the output (defaults to true). the_title().

For other values you will have to alter the function you call. the_author() always shows (echo) the worthiness, you have to call get_the_author() rather.