Thread Starter
mjpg
(@mjpg)
I did a bit more work – it seems like this line is not being triggered:
if ('content_block' == get_post_type()) {
Printing the $post array shows it is holding the main page and not the custom post. ie: [post_type] => page.
Is my theme behaving incorrectly or am I missing something?
Thanks
Thread Starter
mjpg
(@mjpg)
Johan
Yes – although I got it from the readme.txt file.
I’m assuming it’s perhaps an issue with the loop – the function seems to be getting the $posts object from the previous widget.
Thanks for replying.
Martin
Hi Martin,
I have been trying to fix this but hit a brick wall..
The issue is most likely caused by the fact that in version 1.6 of the plugin I switched from using query_post to get_post. Before this change the post thumbnails were working.
The fix would be either switching back to using query_post (which I was told causes performance issues), or getting the thumbnail in the get_post by using setup_postdata($post);.
Unfortunately I did not manage to get this to work. Hopefully someone else reading this will find the solution.
Thread Starter
mjpg
(@mjpg)
Johan
Many thanks for all your efforts.
I’m still using your great plugin for other things, but for this one-off (a promo block on the home page) I created a custom post type called homepromo and wrote a short include to call it. An additional complication that may have caused another issue with your function is that I needed the image in the CSS background.
This is the content of my include file in case it is of use to anyone else – themename-homepromo.php:
<?php if( is_front_page() ) { ?>
<?php
$args = array( 'post_type' => 'homepromo' , 'posts_per_page' => 1 );
$homepromoloop = new WP_Query( $args );
?>
<?php if ( $homepromoloop->have_posts() ) { ?>
<?php while ( $homepromoloop ->have_posts() ) : $homepromoloop ->the_post(); ?>
<?php
$featured_image_id = get_post_thumbnail_id( $post->ID );
$imgArray = wp_get_attachment_image_src($featured_image_id,'home_promo');
$imgsrc = $imgArray[0];
?>
<div id="promo" style="background-image:url(<?php echo($imgsrc); ?>);">
<div id="promotext">
<div id="promotextwrapper">
<?php // the_title() NOT USED; ?>
<?php the_content(); ?>
</div><!-- #promotextwrapper -->
</div><!-- #promotext -->
</div><!-- #promo -->
<?php endwhile; ?>
<?php } else echo(''); ?>
<?php } // end is front page ?>
I called it into the index.php with:
<?php get_template_part( "themename", "homepromo" ) ?>
Martin
Hi there, I have the same issue, and have had to resort to inserting an image within the body which may become a little untidy.
Are there any updates on this?
Apart from that I think it’s a great little plugin. Thanks for spending your time to create and share it.