Show WordPress Image Title Under Custom Portfolio Image
Instead of the_title() try this: echo get_the_title($_img). It should only work inside the foreach loop.
Instead of the_title() try this: echo get_the_title($_img). It should only work inside the foreach loop.
Embedded two galleries in the order according to my need. Then used the get_post_galleries to get the galleries in an array.
depend on your code if you use it as gallery shortcode i think this will work : <div class=”gallery-content”> <?php if( has_shortcode( $post->post_content, ‘gallery’ ) ) : if ($ids != ”) { $images = explode(‘,’, $ids); } else { $images = get_children(array(‘post_parent’ => get_the_ID(),’post_type’ => ‘attachment’,’post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order_ID’)) } if ($images) : … Read more
The established technique of passing data to JavaScript in WordPress is wp_localize_script(). Despite the name it’s widely used for arbitrary data, outside of localization purposes. So it is certainly possible to retrieve the necessary data and pass it to the script in this way.
Issue on Getting WP Gallery Items In cpt-single.php As Attachments
How to add gallery support to a custom post type?
Use the same gallery shortcode generated in the visual editor, then add an attribute to note carousel. That way you piggyback on all the functionality with very little extra effort required. See this answer for how to approach this by replacing the default gallery shortcode.
There’s an infinite number of approaches to this. Here’s a couple that come to mind: 1) You could easily use something like strpos() or a regular expression to see if $image[0] contains a keyword. This approach would be a little less than ideal in my opinion. 2) Add a checkbox or ‘tag’ field to the … Read more
While gallery shortcode does have id arguments, it won’t do what you think. If that argument is present WP will try to look for child attachments of that post, using get_children(). It won’t take content of the post and shortcodes in it into account. If the gallery is only content of that page you could … Read more
You can use get_attachment_image(): $att_markup = wp_get_attachment_image( $attachment->ID, ‘thumbnail’ ); Or get_attachment_link(): $att_link = wp_get_attachment_link( $attachment->ID, ‘thumbnail’ );