I have a user review site built with Wordpress and can't seem to get just one category to show on home page.
I have tried:
<?php get_header(); ?>
<?php $top_counter=1 ?>
<?php
$blog_hero = of_get_option('blog_hero');
if ($blog_hero && ! is_category()){
?>
<div class="clearfix row-fluid">
<div class="hero-unit">
<h3>thanks stack-exchange help needed.</p>
<br />
</p>
</div>
</div>
<?php
}
?>
<div id="content" class="clearfix row-fluid">
<div id="main" class="span8 clearfix" role="main">
<? function customf_process_wp_query($posts_data,$post_type=null,$post_rate=null){
wp_reset_query();
query_posts($posts_data);
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
if($post_type==3){
$in_top=false;
foreach($post_rate as $key=>$top_post_id){
if($top_post_id->ID==get_the_ID()) $in_top=true;
}
if($in_top) continue;
}
?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article">
<header>
query_posts( array('your-custom-taxonomy' => 'category name', 'post_type' => 'your_post_type_here') );
replace the above code with
query_posts($posts_data);
and replace your-custom-taxonomy and your_post_type_here with required arguments.
Hope this will help
Using the standard loop initialiser:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
Just change to:
<?php if ( have_posts() ) : while ( have_posts() && the_category() == $home_page_cat ) : the_post(); ?>
Related
In this code videos are shown at random. I wanted to show them as selected category (i-e= 'links' category). How can I write this code to work for the links category?
<?php if( !defined('ABSPATH') ) exit; global $awpt; ?>
<div class="being_watched">
<div class="heading">
<?php $h_tag = $awpt['live_videos_heading']; $title = $awpt['beingwatched_title'];
echo '<'.$h_tag.'>'.$title.'</'.$h_tag.'>' ?>
</div>
<div class="row">
<div class="col-md-12">
<ul class="Thumbnail_List">
<?php
$per_page = $awpt['watched_now_videos'];
query_posts('showposts='.$per_page.'&orderby=rand');
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php do_action( 'bestia_thumbnail_compatibility' ); ?>
<?php endwhile; else: endif; ?>
</div>
</div>
<?php wp_reset_query(); ?>
</ul>
</div>
I would like to display post from only one category. How should I change this function?
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('post_type' => 'post','paged' => $paged);
query_posts($args);
if ( have_posts() ) :
while ( have_posts() ) : the_post();
get_template_part( 'post-format/content', get_post_format() );
endwhile;
else:
get_template_part( 'post-format/content', 'none' );
endif;
?>
<?php
/*
Template Name: Boats'n'Hoes
*/
?>
<?php get_header(); ?>
<div id="main">
<div id="content" class="narrowcolumn">
<?php
query_posts('cat=1');
while (have_posts()) : the_post();
the_content();
endwhile;
?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
reference :- https://wordpress.org/support/topic/display-the-posts-of-one-category-in-a-page-solved
Something I created for a client was a template that lists posts from a category that has the same name as the page.
So, create a Page called "funnies" if you want to list all posts in the "technology" category.
Oh, and the original content of the Page is displayed too, if you need an introductory text.
<?php /*
Template Name: ListPostsInCategoryThatHasSameNameAsPage
*/ ?>
<?php get_header(); ?>
<div id="content">
<div id="main">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php endwhile; else: endif; ?>
<?php query_posts('category_name='.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?>
<?php endwhile; else: endif; ?>
</div>
</div>
<?php get_footer(); ?>
Pass this with $args
'category_name' => 'cat-name',
after adding the function of pagination to Functions.php and recall it in template-product-listing.php
there is nothing shown in result.
I have a big problom with this...
could you find and resolve the problem?
thnx
<article class="row">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="single-head" class="sixteen columns">
<h1><?php the_title(); ?></h1>
<?php if (has_excerpt()) { the_excerpt(); } ?>
</div>
<div class="row">
<nav id="portfolio-filters" class="sixteen columns">
<?php _e('Show All', 'ci_theme'); ?>
<?php
$args = array(
'hide_empty' => 0
);
$skills = get_terms('product-category', $args);
?>
<?php foreach ( $skills as $skill ) : ?>
<?php echo $skill->name; ?>
<?php endforeach; ?>
</nav><!-- /portfolio-filters -->
</div>
<div id="portfolio-items" class="row">
<?php $ci_product_query = new WP_Query('post_type=product&posts_per_page=4'); ?>
<?php if ( $ci_product_query-> have_posts() ) : while ( $ci_product_query->have_posts() ) : $ci_product_query->the_post(); ?>
<?php $item_skills = wp_get_object_terms($post->ID, 'product-category'); ?>
<article class="<?php ci_e_setting('product_columns'); ?> columns <?php foreach ( $item_skills as $item_skill ) : echo $item_skill->slug.' '; endforeach; ?> columns portfolio-item">
<a href="<?php echo get_permalink(); ?>" title="<?php echo esc_attr(get_the_title()); ?>" class="fb">
<?php the_post_thumbnail('ci_portfolio_slider', array('class'=>'scale-with-grid')); ?>
</a>
<div class="portfolio-desc">
<h3><?php the_title(); ?></h3>
<p class="desc"><?php echo mb_substr(get_the_excerpt(), 0, 70); ?>...</p>
</div>
</article><!-- /portfolio-item -->
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>
</div><!-- /portfolio-items -->
<?php get_template_part('part', 'call_to_action'); ?>
<?php endwhile; endif; ?>
<div class="pagination">
<?php wp_pagination(); ?>
</div>
</article>
if your sure there is a post_type called products and there is posts in it...
try:
<div id="portfolio-items" class="row">
<?php $ci_product_query = new WP_Query(array('post_type'=>'product', 'posts_per_page'=> 4); ?>
<?php if ( $ci_product_query-> have_posts() ) : while ( $ci_product_query->have_posts() ) : $ci_product_query->the_post(); ?>
You know you are starting a new wp_query for every post in have_posts() ? you might want to rethink what you are trying to achieve!
I have this code for my page template.
This is what i have right now: http://www.ohright.com/emoticons/
How do I change it so that it can display all my post images at 20 images per-page and with a pagination below?
<?php
/*
Template Name: emoticons-page
*/
get_header(); ?>
<div id="content">
<div id="main">
<?php query_posts('cat=44'.get_the_title().'&post_status=publish,future');?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?>
<?php endwhile; else: endif; ?>
</div>
</div>
<?php get_footer(); ?>
<?php
/*
Template Name: emoticons-page
*/
get_header(); ?>
<div id="content">
<div id="main">
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$posts_per_page = 20;
query_posts('cat=44&post_status=publish&paged=' . $paged . '&posts_per_page=' . $posts_per_page);?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<p><?php the_content(); ?>
<?php endwhile;
posts_nav_link();
wp_reset_query();
endif; ?>
</div>
I want to have my latest post show up with all info(title, author, thumbnail, and content) but only the title of the second most recent post in another div. Here is my code. It renders the divs correctly but the 'title' in the second div is the 'title' of the latest post still.
<div id="blog-pane">
<div id="blog-post">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="post-title">
<?php the_title(); ?>
</div>
<div id="post-author">
<?php the_author(); ?>
<?php the_date(); ?>
<?php the_time(); ?>
</div>
<div id="post-image">
<?php the_post_thumbnail(); ?>
</div>
<div id="post-text">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php rewind_posts(); ?>
</div>
<div id="post-link-1">
<?php
query_posts( 'p' );
while ( have_posts() ) : the_post();
the_title();
endwhile;
wp_reset_query();
?>
</div>
</div>
</div>
<?php get_footer(); ?>
you can try to introduce some skip logic to have it skip the first post,
<div id="post-link-1">
<?php
query_posts( 'p' );
$count = 0;
while ( have_posts() ) {
if ($count++ == 0) {
the_post();
continue;
}
the_post();
the_title();
}
wp_reset_query();
?>
</div>