• Thanks in advance for the direction, folks. I am looking to post one day’s worth of blog posts on the front page of my blog. If I have one post, the blog would print that one post. If I have 20, it prints 20 posts.

    I assume that there is a special Page that will do this and I should direct the site to use that Page as my front page.

    Help!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter billdennis6

    (@billdennis6)

    Thanks. So, what I want to do is create a Page using this time parameter, and point toe front page to this new Page.

    $today = getdate();
    $query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );

    Exactly where on the Page I’ll create (Ill call it “today.php’) should i insert this parameter?

    Again, thanks for all your help.

    Just before the start of the Loop.

    Thread Starter billdennis6

    (@billdennis6)

    Thank you!!!

    Thread Starter billdennis6

    (@billdennis6)

    Ok, I have ONE question:

    Exactly where does the LOOP start on this index page:

    <div id="content">
    
    	<?php if (have_posts()) : ?>
    
    <a href="https://blogpeoria.com/"><div align="center"><img src="https://blogpeoria.com/files/2012/04/blogpeoriabanner.png" width="550"></div></a><br>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2 class="posttitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'f2'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
    				<div class="postmetadata">
    				<?php if(f2_option('show_author') == 'on') : ?>
    				<?php _e('Posted by', 'f2'); ?> <span class="postauthor"><?php the_author_posts_link(); ?></span> <?php _e('on', 'f2'); ?> ...

    Thanks. Dumb question, I know …

    <?php if (have_posts()) : ?>

    Thread Starter billdennis6

    (@billdennis6)

    So, forgive me for being dense, but is THIS what I have to add right above The Loop?

    <?php
    
    // The Query
    
    $today = getdate();
    $query = new WP_Query( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] );
    
    // The Loop
    while ( $the_query->have_posts() ) : $the_query->the_post();
    	echo '<li>';
    	the_title();
    	echo '</li>';
    endwhile;
    
    // Reset Post Data
    wp_reset_postdata();
    
    ?>

    Yes.

    if you want to use this with the code from https://www.ads-software.com/support/topic/todays-blog-posts-only-on-front-page-of-my-blog?replies=9#post-2727222 then try to add just this section before this line <?php if (have_posts()) : ?>:

    <?php $today = getdate();
    queryposts( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] . '&posts_per_page=-1' );
    ?>

    if you do this in index.php or if you need to create a home.php depends on your theme and how it uses index.php.

    possibly wrap the query into a conditional statement:

    <?php if( is_home() ) :
    $today = getdate();
    queryposts( 'year=' . $today["year"] . '&monthnum=' . $today["mon"] . '&day=' . $today["mday"] . '&posts_per_page=-1' );
    endif; ?>
    Thread Starter billdennis6

    (@billdennis6)

    Boy. each time I add that line, it breaks my blog. The blog stops rendering when it reached that line of code.

    whereever you add whatever code, please make sur eto take care of the php tags; i.e. be aware if you are adding the code into an already open php tag, or if you need to open a new php tag.

    do you get any error message?

    what is the total code of that template?

    Thread Starter billdennis6

    (@billdennis6)

    Here is is:

    [62 lines of code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Thread Starter billdennis6

    (@billdennis6)

    I’m sorry, this didn’t come through. You can look at the page’s entire code here:

    https://pastebin.com/GyaCXBqF

    All the php tags are closed. I am not getting any error messages. It’s just that when I pate ANY Query code before the Look, the page stops rendering.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Today's blog posts ONLY on front page of my blog’ is closed to new replies.