• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

How to change the order of the months for navigation grouped by year using PHP & SQL I'm making a navigation for the WordPress posts grouped by year using SQL. My code is working but I'd like to change the order of months like below.

Current results

2019  12 11 10 9 8 7 6 5 4 3 2 1

2018  12 11 10 9 8 7 6 5 4 3 2 1

I'd like to change the order of month like this

2019  1 2 3 4 5 6 7 8 9 10 11 12

2018  1 2 3 4 5 6 7 8 9 10 11 12

$today = date( 'Y-m-d' ); $year_prev = null; $months = $wpdb->get_results("SELECT DISTINCT MONTH( post_date ) AS month,     YEAR( post_date ) AS year,     COUNT( id ) as post_count FROM $wpdb->posts     WHERE post_status = 'publish' and post_date <= now( )     and post_type = 'post'     GROUP BY month , year     ORDER BY post_date DESC"); foreach($months as $month) : $year_current = $month->year; if ($year_current != $year_prev){ if ($year_prev != null){?>   year; ?>   
Download script demo [LINK] [Origin]
Download script demo [LINK 2] [Onedrive] Download script demo [LINK 2] [Google drive]