Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1447359

    Hi, is it possible to make a structure in the backend by the lists of posts so that i can sort the posts into folders by year, than month so that i have a better overview?

    i have a big list of posts and its getting difficult to sort them after their date.In the moment i sort them by drag and drop
    Would be great if there is a plugin or other possibility :)

    Many regards rixi

    #1447382

    Hey rixi,
    Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor or If you are not using a child theme you could use the WP Code plugin then add a new snippet, in the top right corner use the PHP snippet as the code type:
    use wpcode php snippet and activate
    and ensure that it is activated, then add this code and save.

    // Add year filter to posts and pages admin listing
    function filter_posts_by_year() {
        global $wpdb, $wp_query;
    
        $type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
        if ($type === 'post' || $type === 'page') {
            $year = isset($_GET['year']) ? $_GET['year'] : '';
    
            // Get distinct years from the posts table
            $years = $wpdb->get_col("
                SELECT DISTINCT YEAR(post_date)
                FROM $wpdb->posts
                WHERE post_type = '$type' AND post_status = 'publish'
                ORDER BY YEAR(post_date) DESC
            ");
            ?>
            <select name="year" id="filter-by-year">
                <option value=""><?php _e('All Years', 'textdomain'); ?></option>
                <?php
                foreach ($years as $year_option) {
                    printf(
                        '<option value="%1$s"%2$s>%1$s</option>',
                        esc_attr($year_option),
                        $year_option == $year ? ' selected="selected"' : ''
                    );
                }
                ?>
            </select>
            <?php
        }
    }
    add_action('restrict_manage_posts', 'filter_posts_by_year');
    
    function filter_posts_by_year_query($query) {
        global $pagenow;
    
        $type = isset($_GET['post_type']) ? $_GET['post_type'] : 'post';
        if ($type === 'post' || $type === 'page') {
            if ($pagenow == 'edit.php' && isset($_GET['year']) && $_GET['year'] != '') {
                $year = intval($_GET['year']);
                $query->query_vars['year'] = $year;
            }
        }
    }
    add_filter('parse_query', 'filter_posts_by_year_query');
    

    This is add a new filer option for your pages & posts:
    Enfold Support 5981
    Enfold Support 5983

    Best regards,
    Mike

    #1447411

    Good morning,
    very cool! Thanks a lot Mike
    Best support :) Have a nice day :)

    Many regards rixi

    #1447429

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Pusts in foldersystem’ is closed to new replies.