Forums

How to get the blog post's featured image, content, last modified date and comme (4 posts)

  1. hmdnawazz
    Member
    Posted 1 year ago #

    I have a wordpress site in which I want to create a blog page which will display the following things.

    The blog's featured image in first line
    The blog title in the second line
    The blog content(text) in the third line
    The last update, comments count and posted by in the 4th line.
    How will I do this?

    Shoud I directly query the database or use some builtin functions?

    Any help?

  2. shaile
    Member
    Posted 1 year ago #

    1- Feature Image

    <?php
    					$images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
    					if ( $images ) {
    					$total_images = count( $images );
    						$image = array_shift( $images );
    						echo $image_img_tag = wp_get_attachment_image( $image->ID, 'thumbnail' );
    						}

    2-Title

    <?php the_title();?>

    3- Content <?php the_content();?>

    4- Comments <?php comments_number( 'no responses', 'one response', '% responses' ); ?>.

    /@@@@@@@@@@@@@@@@@@@@@ Code /

    [Code moderated as per the Forum Rules. Please use the pastebin]

  3. hmdnawazz
    Member
    Posted 1 year ago #

    I tried your code but did nor resolve the problem.
    Nothing displayed.

  4. shaile
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags