-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Problem with the latest release of the plugin, reported by email:
One of our clients uses your WP plugin for their Image Rotator on the home page (post ID 94
), and updating to your latest version (1.10) from 1.9.1 is causing an issue with the images displaying.
From what I can tell, our issue is from the updated file, cptbc-frontend.php
(~ line 74-81), and with the changed variable $post_id
to get_the_ID()
function:
CPT-Bootstrap-Carousel/trunk/cptbc-frontend.php
Lines 73 to 81 in 21d7d9f
$content = get_the_excerpt(); | |
$image = get_the_post_thumbnail( get_the_ID(), $atts['image_size'] ); | |
$image_src = wp_get_attachment_image_src(get_post_thumbnail_id(), $atts['image_size']); | |
$image_src = $image_src[0]; | |
$url = get_post_meta(get_the_ID(), 'cptbc_image_url', true); | |
$url_openblank = get_post_meta(get_the_ID(), 'cptbc_image_url_openblank', true); | |
$link_text = get_post_meta(get_the_ID(), 'cptbc_image_link_text', true); | |
$video_url = get_post_meta(get_the_ID(), 'cptbc_video_url', true); | |
$video_aspect = get_post_meta(get_the_ID(), 'cptbc_video_aspect', true); |
An issue occurs if the image carousel item doesn't have an "Excerpt". Then the line $content = get_the_exceprt();
seems to revert to the global $post
for the home page (post ID 94
) and then updates the global $post
so that get_the_ID()
then returns the home page ID and not the image carousel item (therefore not displaying the image).
I think you should revert back to your variable $post_id
, or check to make sure you're looking at the right post_id, or possibly rename the excerpt for the image carousel items and create a new function to retrieve that attribute. Unsure on the best fix here.
This may be helpful, add this function to your cpt-bootstrap-carousel.php
file:
https://www.codee.io/wordpress-excerpt-using-post-id/
then change $content = get_the_excerpt()
to that new function custom_get_the_excerpt($post_id);