404 error with the date in the archive news

Support Forums for LiveMesh Themes & Plugins Forums Invent Theme Support 404 error with the date in the archive news

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #24400
    maxellmarcus
    Member

    Hi code master,
    in my archive news: http://www.scuoladipaloalto.ch/rassegnastampa/ when clicking on the date of every single post occurred 404 error.
    Missing a php rule in my archive?

    Thank you in advance for your precious support.

    #24433
    Veena
    Moderator

    Can you pls try the below code in your theme’s functions.php or in your child theme’s fuctions.php file and see if this helps.

    
    function custom_post_date_archive($query) {
        if ($query->is_date)
            $query->set( 'post_type', array('post', 'news') );
        remove_action( 'pre_get_posts', 'custom_post_author_archive' );
    }
    add_action('pre_get_posts', 'custom_post_date_archive');
    
    #24434
    maxellmarcus
    Member

    Unfortunately I have the same error.

    #24447
    Veena
    Moderator

    This code works for my archive news page .
    If you are asking this for a newly created custom post type then you have to include that specific post name like this –

    
     function custom_post_date_archive($query) {
        if ($query->is_date)
            $query->set( 'post_type', array('post', 'news','rassegnastampa') );
            remove_action( 'pre_get_posts', 'custom_post_author_archive' );
    }
    add_action('pre_get_posts', 'custom_post_date_archive');
    

    ie, here –

    
    $query->set( 'post_type', array('post', 'news','rassegnastampa') );
    

    you have to add the required custom post name.

    #24448
    maxellmarcus
    Member

    It works.
    Thanks again for your help

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘404 error with the date in the archive news’ is closed to new replies.