LittleBrother
Forum Replies Created
Viewing 5 replies - 1 through 5 (of 5 total)
-
Thanks. Got the correct class. It’s better to add the resource link beside that setting.
Forum: Fixing WordPress
In reply to: Display specific post at top with other post belongs to a categoryThanks. I modified my code according to your suggestion.
<?php if( is_category() ) : $args = array( 'posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1 ); else : $args = array( 'posts_per_page' => 2, 'orderby' => 'post_date', 'order' => 'desc' ); endif; $the_query = new WP_Query($args); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="film singleBox first tallBox" style="width:100%"> <div class="filmInside"> <a href="<?php the_permalink(); ?>"> <?php if( has_post_thumbnail() ) { the_post_thumbnail('small-thumb', array( 'class' => 'layout-2-thumb' ) ); echo '<div class="struggleTitle midGrey">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>'; echo '<div class="struggleDescription whiteColor">' .'<p>'. get_post(get_post_thumbnail_id())->post_content . '</p>'. '</div>'; } else{ echo '<img src="'.get_template_directory_uri().'/images/no-image.png" class="layout-2-thumb">'; } ?> </a> </div> </div> <?php endwhile; ?> <?php wp_reset_postdata(); ?> <?php endif; ?>
With this i get only latest one sticky post. Same sticky post in every category.
I wish to get sticky post at top according to category and another post under that sticky video. Just like as my image.
Forum: Fixing WordPress
In reply to: Display specific post at top with other post belongs to a categoryoh,yes. I used this.
<?php if( is_category() ) : $args = array( 'posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1 ); $the_query = new WP_Query('$args&showposts=2&cat='.get_query_var('cat')); else : $the_query = new WP_Query('showposts=1&orderby=post_date&order=desc'); endif; ?> <?php if( $the_query->have_posts() ) : while( $the_query->have_posts() ) : $the_query->the_post() ?> <div class="film singleBox first tallBox" style="width:100%"> <div class="filmInside"> <a href="<?php the_permalink(); ?>"> <?php if( has_post_thumbnail() ) { the_post_thumbnail('small-thumb', array( 'class' => 'layout-2-thumb' ) ); echo '<div class="struggleTitle midGrey">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>'; echo '<div class="struggleDescription whiteColor">' .'<p>'. get_post(get_post_thumbnail_id())->post_content . '</p>'. '</div>'; } else{ echo '<img src="'.get_template_directory_uri().'/images/no-image.png" class="layout-2-thumb">'; } ?> </a> </div> </div> <?php endwhile; endif; ?> <?php wp_reset_postdata(); ?>
Forum: Fixing WordPress
In reply to: Display specific post at top with other post belongs to a category<?php if( is_category() ) : $args = array( 'posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1 ); $the_query = new WP_Query('$args&showposts=2&cat='.get_query_var('cat')); else : $the_query = new WP_Query('showposts=2&orderby=post_date&order=desc'); endif; ?> <?php if( $the_query->have_posts() ) : while( $the_query->have_posts() ) : $the_query->the_post() ?>
*updated
Forum: Fixing WordPress
In reply to: Display specific post at top with other post belongs to a categoryThanks esmi
But that idea didn’t work. I don’t get sticky post under category than latest post.
Used this –$args = array( 'posts_per_page' => 1, 'post__in' => get_option( 'sticky_posts' ), 'ignore_sticky_posts' => 1 ); $query = new WP_Query( $args );
Viewing 5 replies - 1 through 5 (of 5 total)