• Resolved wlansell

    (@wlansell)


    Hello,

    Get plugin, about time WP made this part of the whole package.

    Anyway, I’m trying to get the dynamic featured images showing through out the content using the phpcode below

    <?php $paragraphAfter[1] = '<div>AFTER FIRST</div>'; //display after the first paragraph
    $paragraphAfter[3] = '<div>AFTER THIRD</div>'; //display after the third paragraph
    $paragraphAfter[5] = '<div>AFTER FIFtH</div>'; //display after the fifth paragraph
    
    $content = apply_filters( 'the_content', get_the_content() );
    $content = explode("</p>", $content);
    $count = count($content);
    for ($i = 0; $i < $count; $i++ ) {
        if ( array_key_exists($i, $paragraphAfter) ) {
            echo $paragraphAfter[$i];
        }
        echo $content[$i] . "</p>";
    }?>

    How do I go about incorporating the display if each featured image..?

    <?php if( class_exists('Dynamic_Featured_Image') ) {
    	global $dynamic_featured_image;
    	global $post;
    	$featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
    
    	foreach($featured_images as $image) {
    	$url = $image['full'];
    	$caption = $dynamic_featured_image->get_image_caption($image['full']);
    	$title = $dynamic_featured_image->get_image_title($image['full']);
    
    	//print_r($featured_images);
    
    	echo "<div class='side-thumb'><div class='screenshot'>";
    	echo "<a href='".$image['full']."' alt='".$caption."' title='".$title."' rel='lightbox'>";
    	echo "<img src='".$url."' title='".$title."' />";
    	echo "</a><div class='screenshot-caption screenshot-caption_right'><h3>";
    	echo $caption;
    	echo "</h3></div></div></div>";
    
    	}
    }
    ?>

    Thanks
    Wayne

    https://www.ads-software.com/plugins/dynamic-featured-image/

Viewing 1 replies (of 1 total)
  • Plugin Author Ankit Pokhrel

    (@ankitpokhrel)

    Hi wlansell,

    If I understood you correctly, you can do something like this:

    global $dynamic_featured_image;
    $first_featured_image = $dynamic_featured_image->get_nth_featured_image(2); //count starts with 2
    $second_featured_image = $dynamic_featured_image->get_nth_featured_image(3);
    $third_featured_image = $dynamic_featured_image->get_nth_featured_image(4);
    
    $paragraphAfter[1] = '<div>AFTER FIRST</div>';
    //display after the first paragraph
    echo "<img src='{$first_featured_image['full']}' />";
    
    $paragraphAfter[3] = '<div>AFTER THIRD</div>';
    //display after the third paragraph
    echo "<img src='{$second_featured_image['full']}' />";
    
    $paragraphAfter[5] = '<div>AFTER FIFtH</div>';
    //display after the fifth paragraph
    echo "<img src='{$third_featured_image['full']}' />";

    Regards,
    Ankit

Viewing 1 replies (of 1 total)
  • The topic ‘Place Images throughout the content’ is closed to new replies.