mixed in with some CSS, im getting just about everything I want from this short code. However when using custom CSS, it is not to easy getting the “post title” to float above the featured image thumbnails. by float above I mean…be displayed above the thumbnail

the post title link is very stubborn, and wont budge from being on the left side of the thumbnails. I want the title above the post thumbnails.

also note. it seems the post title is somehow connected with the post thumbnail. im sensing this is something to do with this code.

anyone got some answers to this?

/*
=================================
Displays posts from specified category on homepage
=================================

*/

add_filter( ‘category_description’, ‘do_shortcode’);

function wpb_postsbycategory() {
// the query
$the_query = new WP_Query( array( ‘category_name’ => ‘crazy-humorous-pictures, strange-news-stories’, ‘posts_per_page’ => 10 ) );

// The Loop
if ( $the_query->have_posts() ) {
$string .= ”;
while ( $the_query->have_posts() ) {
$the_query->the_post();
if ( has_post_thumbnail() ) {
$string .= ‘

  • ‘;
    $string .= ” . get_the_post_thumbnail($post_id, array( 500, 500) ) . get_the_title() . ‘
  • ‘;
    } else {
    // if no featured image is found
    $string .= ‘

  • ‘ . get_the_title() . get_the_content() .’
  • ‘;
    }
    }
    } else {
    // no posts found
    }
    $string .= ”;

    return $string;

    /* Restore original Post Data */
    wp_reset_postdata(); }

    // Add a shortcode
    add_shortcode(‘categoryposts’, ‘wpb_postsbycategory’);

    // Enable shortcodes in text widgets
    add_filter(‘widget_text’, ‘do_shortcode’);

    Read more here: CSS not responding well with Shortcode


    Solution:

    If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


    Wordpress related questions and answers: