display specific info from RSS
-
I need help. I have very limited knowledge of coding, but I’m trying to teach myself, so I really need some help.
I am running 2 sites…one is my photoblog, and on the other I want to display the 12 most recent images from my photoblog. I have set up the RSS feed to include images, and all is well. The second site very nicely displays the images from the photoblog site and even includes the names of the images. I also want to include the EXIF data from the photoblog on the second site.
I’m trying to understand how I can pull just the EXIF data out to display. currently, all I get is either nothing or everything…the path to the image, it’s dimensions, all the EXIF data, etc. I’ve tried both
get_content()
andget_description
, but I can’t seem figure out how to isolate just the EXIF data.Here’s the code I’m using. Again, All I want from the content is the EXIF data.
<?php $feed = fetch_feed('https://www.mysite.com/feed/'); if (!is_wp_error( $feed ) ) : $maxitems = $feed->get_item_quantity( 12 ); $rss_items = $feed->get_items( 0, $maxitems ); endif; ?> <?php function get_first_image_url($html) { if (preg_match('/<img.+?src="(.+?)"/', $html, $matches)) { return $matches[1]; } } ?> <?php if ($maxitems == 0) echo '<li>No items.</li>'; else foreach ( $rss_items as $item ) : ?> <article class="photos"> <a target="_blank"href='<?php echo esc_url( $item->get_permalink() ); ?>'> <div class="photo-image"> <?php echo '<img src="' .get_first_image_url($item->get_content()). '"/>'; ?> </div><!--.photo-image --> <div class="photo-info"> <h3 class="photo-title"><?php echo esc_html( $item->get_title() ); ?></h3> <h3 class="photo-caption"><?php echo esc_html( $item->get_content() ); ?></h3> </div><!--.photo-info --> </a> </article> <?php endforeach; ?>
Thanks so much in advance. I greatly appreciate it.
- The topic ‘display specific info from RSS’ is closed to new replies.