Closed guuthemes closed 10 years ago
You'll need to get the ID of the page you set as the front page or posts page in the Settings/Reading/Front page displays option. If you are using it on a page set as front page you'll need to pass get_option( 'page_on_front' )
as the third parameter to MultiPostThumbnails::the_post_thumbnail()
. If you are using it on a page set as a posts page, you'd need to pass in get_option( 'posts_page' )
instead. If you need to cover both cases, use the is_home()
and is_front_page()
conditionals.
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_option('posts_page'), 'header-image', NULL, 'header-image-full'); endif; ?>
is returning no output?
get_option('posts_page')
gets the post ID of the posts landing page. You want that as the third parameter in the function call; the first should still be the post type, which in this case would be 'page'
.
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail('page', 'header-image', 'posts_page', NULL, 'header-image-full'); endif; ?>
Am I missing something here?
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail('page', 'header-image', get_option('posts_page'), 'header-image-full'); endif; ?>
First parameter is the post type, third is the post ID (which you get from the option).
Doh!! Late night. Thanks. I'll try that.
Works. Only tweak I had to make is, it's page_for_posts, not posts_page.
thanks
Hey, great work, but having an issue with trying to show an image when a Blog page is set. It does not pull the featured image that has been set for the blog page, but more the image from the first post??
The code I have currently is -
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'header-image', NULL, 'header-image-full'); endif; ?>
And then in header.php I have done (as I have slightly differing text) -
if is_page (works great)
else is_singular (works great)
else is_home (this is where the issue arises)
Any pointers dude?
Many thanks