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

widget change "post slider" into "page slider" WordPress

  • REFUNDED

Hello,

I'm using the Templatic Enterprise Theme (http://templatic.com/demos/?theme=enterprise).

As you see there is a Content Slider. In the Widget menu I can type in an category ID so only some posts are shown.

But I would like to use the Slider for page contents.

I'm looking for someone who can change this for me so I can also type in page IDs which shall be shown in the Slider. And of course PAGES and not posts.

Please contact me.
Thanks!

Answers (2)

2011-07-09

Suhas Sharma answers:

This is a simple WP_Query..

http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

$query = new WP_Query( array( 'post__in' => array( 2, 5, 12, 14, 20 ) ) );


donald91 comments:

but where to change?
this is the main part of the slider-code:

<?php
global $post,$wpdb;
if($category)
{
$catids = $category;
$sub_sql_cat = " and t.term_id in ($catids)";
}
$catQuery = $wpdb->get_results("select t.* from $wpdb->terms t join $wpdb->term_taxonomy tt on tt.term_id=t.term_id where tt.taxonomy=\"category\" $sub_sql_cat order by t.name");
$counter=0;
foreach ($catQuery as $category) {
$catLink = get_category_link($category->term_id);
$categoryid = $category->term_id;
$categoryname = $category->name;
$sql = "select p.* from $wpdb->posts p where p.post_type='post' and p.ID in (select tr.object_id from $wpdb->term_relationships tr join $wpdb->term_taxonomy t on t.term_taxonomy_id=tr.term_taxonomy_id where t.term_id=\"$categoryid\" ) order by p.post_date desc,p.ID desc limit 1";
$featureposts_obj = $wpdb->get_results($sql);

if($featureposts_obj){
setup_postdata($featureposts_obj);

$postperslide = $post_per_slide;
foreach($featureposts_obj as $post)
{
if($counter=='0' || $counter%$postperslide==0){ echo "<li>";}?>
<div class="post_img">
<div class="post_img_in">
<div class="postimg">
<?php
if(get_the_post_thumbnail( $post->ID, array()))
{?>
<a href="<?php echo get_permalink($post->ID);?>"><?php echo get_the_post_thumbnail( $post->ID, array(238,136),array('class' => "",));?></a>
<?php
}
elseif( $post_images = bdw_get_images($post->ID,'large'))
{
global $thumb_url;
?>
<h5><a href="<?php echo $catLink;?>"><?php echo $categoryname?></a></h5>
<a href="<?php echo get_permalink($post->ID);?>">
<img src="<?php echo get_bloginfo('template_url');?>/thumb.php?src=<?php echo $post_images[0];?>&amp;w=238&amp;h=136&amp;zc=1&amp;q=80<?php echo $thumb_url;?>" alt="<?php echo get_the_title($post->ID);?>" title="<?php echo get_the_title($post->ID);?>" /></a>
<?php
}else{
?>
<a href="<?php echo get_permalink($post->ID);?>">
<span class="noimage"><?php _e('Image Not Available','templatic')?></span></a>
<?php }?>
</div>
<div class="postcontent">
<h3><span class="title"><a href="<?php echo get_permalink ($post->ID);?>" title="<?php echo get_the_title($post->ID);?>" ><?php echo get_the_title($post->ID);?></a></span></h3>
<?php
$text = $post->post_content;
$text = strip_tags($text);
$text = substr($text, 0, 100);
$text = substr($text, 0, strrpos($text, " "));
?>
<p><?php echo $text.$ellipsis;?></p>
</div></div></div>
<?php
$counter++;
if($counter%$postperslide==0){ echo "</li>";}
}
}
} ?>

2011-07-11

Duncan O'Neill answers:

Try this;

1) make a backup of the file.

2) Replace all the code from the line which begins $catQuery, down to, but NOT INCLUDING <div class="post_img"> with this;


wp_reset_query();
$args = array('post_type'=>'page',"post__in"=>$catids,'numberposts'=>-1);

$catQuery = get_posts($args);

$counter=0;

foreach ($catQuery as $post) {

if($post){
setup_postdata($post);
if($counter=='0' || $counter%$postperslide==0){ echo "<li>";}



3) Comment out the last closing curly brace before the closing php tag, so that that line looks like //}?>