• i have several cat in my website ! in each category i m calling 4 posts, but i want call only today’s post in every cat, plz help ?

    my Code is :

    <?php
    
    //The Query
    $query = new WP_Query( 'category_name=small International News&posts_per_page=4&offset=1' );
    
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    	$queried_post = get_post($cat_id); ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
    	<h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    	<?php echo '</li>';
    endwhile;
    echo '</ul>';
    	?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter fzishk

    (@fzishk)

    i used that Query but its not working ,i m not gud in Php so can you tell me where i have to use that time Query ?

    <?php
    //The Query
    $today = getdate();
    $query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
    $query = new WP_Query( 'category_name=small-Business News&posts_per_page=4&offset=1' );
    
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    	 ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
    	<h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    	<?php echo '</li>';
    endwhile;
    echo '</ul>';
    
    	?>

    only use one query – combine the parameters;

    try:

    $query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] . '&category_name=small-business-news&posts_per_page=4&offset=1' );

    important: check the category_name which needs to be the slug of the one category you want to show (I changed it above, but this is just a guess)

    Thread Starter fzishk

    (@fzishk)

    thnx alot Problem Solved 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘how to show only today's posts’ is closed to new replies.