Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Make Flexslider use sticky posts WordPress

  • SOLVED

Hi everyone.

So, I have tried this myself but unfortunately I am stuck. I saw this code on a tutorial, but I am trying to make it use only sticky posts for the slider. I only have like 12 dollars in my account right now so hopefully we can work with that. Added more but paypal takes a bit to process it.

This code does not work for some reason, here it is below (I am using it in my functions.php since I have a child theme).

function childtheme_flexslider_slider() {
if ( is_home() ) { ?>
<div id="featured-container">
<div class="flexslider">
<ul class="slides">
<?php
query_posts(array('category_name' => 'featured', 'posts_per_page' => 3));
if(have_posts()) :
while(have_posts()) : the_post();
?>
<li>
<?php the_post_thumbnail(); ?>
<p class="flex-caption"><?php the_excerpt(); ?></p>
</li>
<?php
endwhile;
endif;
wp_reset_query();
?>
</ul>
</div>
</div>
<?php }
}
add_action('thematic_abovecontainer', 'childtheme_flexslider_slider');


BTW: Everything is set up correctly, with all the styles and scripts. The slider works with plain htlm type stuff, but not with the above -> which I need to use sticky posts. I hope everything is clear :)

Answers (1)

2012-06-03

Romel Apuya answers:

try this

function childtheme_flexslider_slider() {
if ( is_home() ) { ?>
<div id="featured-container">
<div class="flexslider">
<ul class="slides">
<?php
/* Get all sticky posts */
$sticky = get_option( 'sticky_posts' );

query_posts(array('post__in' => $sticky, 'posts_per_page' => 3));
if(have_posts()) :
while(have_posts()) : the_post();
?>
<li>
<?php the_post_thumbnail(); ?>
<p class="flex-caption"><?php the_excerpt(); ?></p>
</li>
<?php
endwhile;
endif;
wp_reset_query();
?>
</ul>
</div>
</div>
<?php }
}
add_action('thematic_abovecontainer', 'childtheme_flexslider_slider');


Jagst3r15 comments:

Thanks! That worked but could you help with a couple things? It looks a little wacky: http://jagst3r15.com/ - any reason why? Also, how would I then exclude the sticky post from the listing on the front page so that they only appear in the slider.

I hope this isn't too hard - I feel bad about not having more funds available quickly.


Romel Apuya comments:

if you can give me access to the ftp and wp-admin i can probably fix this one for you.