Forums

How to insert code into the_content? (1 post)

  1. robkns
    Member
    Posted 1 year ago #

    Hi,

    this is my code:

    <?php $images = get_children( array( 'post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'excerpt', 'order' => 'DESC', 'numberposts' => 999 ) );
    if ( $images ) :
    
    $total_images = count( $images );
    reset($images);
    $image=current($images);
    
    $thumb_img_tag = wp_get_attachment_image_src( $image->ID, 'large' );?>
    
    <img src="<?php echo $thumb_img_tag[0]; ?>" class="post-img" alt="<?php the_title(); ?>" />

    Code is inside the loop. As you could see, this code returns images form post gallery. It is very helpful.

    But this time i need to insert img into <?php the_content(); ?>. How may i do this?

Topic Closed

This topic has been closed to new replies.

About this Topic