Home › Forums › Pro Support › Always show Image Caption Text
- This topic has 7 replies, 2 voices, and was last updated 2 years, 4 months ago by
elvin.
-
AuthorPosts
-
May 16, 2021 at 11:25 am #30287
createur
ParticipantHi there,
I posted this in GP Forum, but Leo said to post it here.
We are using WP Show Post Pro for outputting posts on the front page and in the right sidebar.
Similar to the Demo Dispatch: https://gpsites.co/dispatch/Our requirement is basically that we need to show the caption text of each featured image. In the single posts we already have set up with the snippet:
https://gist.github.com/diggeddy/5f7c3a4584a8beb51febc9c4f33d6c5cRequired still:
– Front page with (WP Show Posts Pro)
– Sidebar (WP Show Posts Pro)
– Category and tag archiveAnd also, when a post is shared in social Media …
It would be great to output all captions in the upper right corner, like for example:
Any chance to get help?
Best regards.
May 17, 2021 at 9:09 pm #30335elvin
ModeratorHi there,
You’ll have to hook this variable –
$thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment'));
And the conditions that follows it somewhere within your WPSP list.
Depending on what location you placed your image, you can use these hooks.
https://wpshowposts.com/support/topic/bbpress-metadata-and-dates-in-wpshowposts/#post-28854May 17, 2021 at 11:46 pm #30341createur
ParticipantThank you very much.
Would you mind posting a complete sample hook? I am not the best in coding … 🙁
Best regards.
May 18, 2021 at 5:28 am #30360elvin
ModeratorWould you mind posting a complete sample hook? I am not the best in coding …
Where specifically do you want one?
Here’s an example:
add_action('wpsp_before_content',function( $settings ){ if( 123 == (int)$settings['list_id']){ $thumbnail_image = get_posts(array('p' => $post_thumbnail_id, 'post_type' => 'attachment')); if ($thumbnail_image && isset($thumbnail_image[0])) { $image = wp_get_attachment_image_src($post_thumbnail_id, $size); if($thumbnail_image[0]->post_excerpt) echo '<figcaption class="wp-caption thumb-caption">'.$thumbnail_image[0]->post_excerpt.'</figcaption>'; } } });
May 18, 2021 at 8:07 am #30362createur
ParticipantWhere specifically do you want one?
Thank you.
One place is like (Top right):
Our WPSP Shortcode for that is:
[wp_show_posts id=”961″]May 18, 2021 at 6:11 pm #30378elvin
ModeratorThe image link doesn’t seem to be working.
Can you check or post a working link? Viewing the mockup will give us a clearer idea of which hook to use. (and CSS writeup in case needed)
May 25, 2021 at 9:03 am #30611createur
ParticipantThank you.
As I wrote we use same List as on
https://gpsites.co/dispatch/We would need an output of Image caption text here:
Thank you.
May 26, 2021 at 4:50 am #30643elvin
ModeratorHave you tried applying the PHP snippet provided on the previous reply here? https://wpshowposts.com/support/topic/always-show-image-caption-text/#post-30360
Note: Make sure to change
123
with the WPSP ID of the list you want it applied on.Let us know if it’s activated so we can recheck the page to apply the necessary CSS to position it to your preference.
-
AuthorPosts
- You must be logged in to reply to this topic.