display the months of a specific category
I have a website made in wordpress, this website has a file called category-intranet.php that is responsible for showing me all the posts of the category Intranet. what I need is that when the visitor reaches this point, on one side you see all the posts of the category intranet and on the other a kind of sidebar that shows the months ONLY of the category Intranet. I tried with get_month_link(), but this shows all the months of all posts and this does not serve me. here I leave my code
header class=page-header
?php
the_archive_title( 'h1 class=headline color-black', '/h1' );
echo 'br';
if ( category_description() ) {
echo category_description();
}
?
/header
div class=grid
?php
// Start the loop.
echo 'div';
while ( have_posts() ) :
the_post();
echo 'a href=' . get_the_permalink() . '';
echo 'div class=post-access';
the_title( 'h3 class=standard medium color-black', '/h3' );
echo 'p class=standard color-black' . get_the_time( get_option( 'date_format' ) ) . '/p';
echo '/div';
echo '/a';
endwhile;
// Previous/next page navigation.
the_posts_pagination(
array(
'prev_text' = __( 'Previous page', 'twentyfifteen' ),
'next_text' = __( 'Next page', 'twentyfifteen' ),
'before_page_number' = 'span class=meta-nav screen-reader-text' . __( 'Page', 'twentyfifteen' ) . ' /span',
)
);
echo '/div';
endif;
echo 'div';
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
echo ' div class=month
a href=' . get_month_link( '', '' ) . '
p class=standard color-black' . get_the_time( 'F Y' ) . '/p
/a
/div';
} // end while
} // end if
echo '/div';
?
Obviously and before asking here I have used the search engine of the forum and google and I have not found anything. Thank you very much
PS: I also have the archive-intranet.php so that the visitor can get here after clicking on the url
Topic list php categories Wordpress
Category Web