• Hi

    Does anyone know of a block that publishes the posts for that day irrespective of the year please? I asked a while ago and was given some code which worked but I’m not sure how to implement it into a page or post.

    Thanks

    Rich

    • This topic was modified 2 years, 11 months ago by Jan Dembowski.
Viewing 1 replies (of 1 total)
  • Thread Starter Richard Brown

    (@cregy)

    I have spent time reading around and worked out that I need a page template. I have tried to create one based on code I have borrowed from other sources. This is where I am:

    `<?php
    /**
    * Template Name: Today’s Posts Archives
    */

    add_action(‘pre_get_posts’ , function( $query ){
    if ( $query->is_main_query() ) {

    $today = getdate();

    $query->set(‘date_query’, array(
    array(
    ‘day’ => $today[‘mday’],
    ‘month’ => $today[‘mon’]
    ),
    ));
    $query->set(‘post_status’, array(‘publish’, ‘future’));
    }

    return;
    });
    }

    // Start the engine.
    genesis();’

    Unfortunately, I get a critical error. Any ideas please?

Viewing 1 replies (of 1 total)
  • The topic ‘Daily Posts’ is closed to new replies.