Chris Scott
Forum Replies Created
-
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Version and DateThanks for the reminder! Updated in current version, 1.6.
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Get image URLThis is in the FAQ. Note you can pass an image size in as the last parameter if desired.
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Problem passing ID to the_post_thumbnail()That looks correct…
A few things to check (via xdebug or var_dump in the right place):
- That the post with the ID that is
$related_story->ID
actually has a post thumbnail with the id ‘secondary-image’ associated with it and it’s post type is ‘post’. - That
MultiPostThumbnails::the_post_thumbnail()
is getting the correct ID passed in when you pass in$related_story->ID
Forum: Plugins
In reply to: [Multiple Post Thumbnails] get_post_thumbnail_url to return secure version?Due to the way WordPress handles thumbnail urls, your best bet is to just do a string replace on the URL you get back to ensure it is https.
You can do this the same way you’d get the title and caption for any attachment but replace the attachment ID w/the thumbnail ID. e.g. (assumes you are in the loop and your thumbnail id is secondary-image):
$post_thumbnail_id = MultiPostThumbnails::get_post_thumbnail_id( get_post_type(), 'secondary-image', get_queried_object_id() ); $post_thumbnail_post = get_post( $post_thumbnail_id ); $caption = trim( strip_tags( $post_thumbnail_post->post_excerpt ) ); $title = get_the_title( $post_thumbnail_post ); echo esc_html( $caption ); echo esc_html( $title );
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Restrict to certain post ids or templatesSomething I had looked at a while back but haven’t imlemented would be to add something like:
if ( apply_filters( 'mpt_add_metabox', true, $post_type, $post ) ) { // current add_metabox code... }
to the
add_metabox
function. That would allow you to add a filter and inspect the post or use the post type to return true or false which would determine if the metabox is added for that post.If this would work, let me know.
Did you follow the steps at https://www.ads-software.com/plugins/multiple-post-thumbnails/installation/ ?
Assuming the widget uses WordPress’
get_the_post_thumbnail()
function, you should be able to filterget__thumbnail_id_metadata
and return the post ID of the secondary thumbnail to override the featured image’s post thumbnail ID being returned.You need to register an image size for your desired dimensions using
add_image_size()
and then use it as the fourth parameter toMultiPostThumbnails::get_the_post_thumbnail()
.Forum: Plugins
In reply to: [Multiple Post Thumbnails] Release LicenseSpecifically GPL 2.0 as noted in the plugin file itself.
For anyone seeing this, what is the js error from the console?
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Can't get image to display, need help…First, you should change the functions.php code:
'post_type' => 'page'
to
'post_type' => $type
However, the issue with displaying it in front-page.php is likely due to you not being in a loop when calling
MultiPostThumbnails::the_post_thumbnail()
. If that’s the case you need to pass in the post type explicitly as the first argument since get_post_type() won’t work out of the loop (or may have unexpected results).Forum: Plugins
In reply to: [Multiple Post Thumbnails] array for post type parameter do not workThis isn’t a bug per-se since it expects a string and nothing in the docs says it can be and array. Because of the way the thumbnail is registered, accepting an array isn’t a straightforward change to implement.
Forum: Plugins
In reply to: [Multiple Post Thumbnails] get_post_thumbnail_id()Good idea. The code is documented but making it more accessible is always good.
Check out https://voceconnect.github.io/multi-post-thumbnails/ This will be linked up soon.
Forum: Plugins
In reply to: [Multiple Post Thumbnails] Adding rel tag to a linkThe easiest would be to just call
MultiPostThumbnails::get_the_post_thumbnail('products', 'product-thumbnail-1', NULL, 'product-thumbnails')
to get the image and then wrap your A tag w/the rel around that. - That the post with the ID that is