I had created the archive.php file and made it to show all posts, also have a sidebar that shows the time line, for example 2022, january 2022.
When I click on january 2022 I have a page showing me all posts from january 2022, and the url is https://mywebsite.com/2022/01
Now I want to know what is the url to get all the posts?
if I run this code I get the answer blog.
if ( get_option( 'page_for_posts' ) ) {
echo '<a href="'.esc_url(get_permalink( get_option( 'page_for_posts' ) )).'">'.esc_html__( 'All posts', 'textdomain' ).'</a>';
} else {
echo '<a href="'.esc_url( home_url( '/?posts=post' ) ).'">'.esc_html__( 'Blog', 'textdomain' ).'</a>';
}