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>';
  • 1
    Can you please share a screenshot of Settings->Reading from admin side so I can see it. Jan 22 at 5:46
  • added bellow. :) Jan 22 at 12:24
  • So I created a page called blog, then on reading settings had choose post page that blog page that I had created and that is it, is now the blogs page Jan 23 at 0:50

1 Answer 1


here is settings->reading, I have a front-page.php that is why I didnt set the homepage displays

enter image description here

  • So I created a page and then here on the reading settings I had change to static page and choosen the page created for the post page dropdown. Jan 26 at 20:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.