1

I'm using the WP Supersized plugin to load background images on posts and works fine.

The problem I have at this point is I want to show the latest post in cat 17, with custom field key FeaturedOnHomepage, with value yes on my homepage and display the background images from that post. Below the query I use:

        <?php query_posts('cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes'); ?>
        <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>   
        <?php endwhile; ?>    
        <?php else : ?>    
        <?php endif; ?>

Somehow WP Supersized is getting confused and is showing the default image folder (like all images in the Media Library. Do I need to include code to make this work?

2
  • Does supersized behave correctly when you comment that code out?
    – Tom J Nowell
    Aug 22, 2012 at 12:48
  • It does work with the default single.php. No problems at all. Looks like with my custom query WP Supersized doesn't know which post ID it needs to figure out the correct gallery to link.
    – AKNL
    Aug 22, 2012 at 13:05

3 Answers 3

0
query_posts

Avoid this function at all costs. The likely cause of your problem is queries not cleaning up after eachother. Your call to query_posts will have modified the main query ( wasting the original ), and messed up everything following it.

Instead use WP_Query followed by wp_reset_postdata

$query = new WP_Query('cat=17&posts_per_page=1&meta_key=FeaturedOnHomepage&meta_value=yes');
if($query->have_posts()){
    while ($query->have_posts()) {
        $query->the_post();
        ?><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php
    }
    wp_reset_postdata();
} else {
    // you didn't put anything here either
}

You should format your code appropriately, too many , and don't use the if(): endif; stuff, it's cluttering up your code and preventing code editors from matching braces

3
  • Thanks Tom, I changed the query, but still having the same behavior with WP Supersized. I'm using WP Media Gallery (images from the WP Media gallery attached to this page/post will be used) as origin. Maybe that isn;t the best option. Going to try NextGen option. Anyone else has an idea on how to fix this/
    – AKNL
    Aug 22, 2012 at 12:22
  • NextGEN isn't working. It looks like when I'm using a custom query WP Supersized can't find the connected image gallery.
    – AKNL
    Aug 22, 2012 at 12:34
  • I've seen many a person tear their hair out dealing with nextgen. Check your error log
    – Tom J Nowell
    Aug 22, 2012 at 12:47
0

Tried a couple of things:

  • changed query
  • tried all settings in the WP Supersized adminpanel
  • tried custom folder, nextGen, wp gallery options

Nothing worked. The problem is that WP Supersized is confused and doesn't recognizes the attached post gallery origin. Anyone knows a solution to fix this?

0

Never mind. Switched to http://www.ajaxblender.com/bgstretcher-2-jquery-stretch-background-plugin-updated.html

Much more control and working like a charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.