Print dynamically URL of Wordpress posts page

Asked

Viewed 78 times

0

How to make a echo on the post page URL when Wordpress is set to display a page as Homepage and posts on a specific page? For example:

In Settings > Reading it is possible to define a static page and a posts page. What I need is to know if there is a function that takes the posts page dynamically.

Example: echo pegue_a_pagina_de_posts();.
Upshot: http://url-page-post
Obs.: this was only an example. Of course this function does not exist :)


I am developing a theme, so there is no other option. I need to select the post URL dynamically.

1 answer

1

I found the answer. I asked that same question on the official Wordpress forum and I was given the following answer:

get_option( 'page_for_posts' );

The top code returns the ID of the posts page. To get the URL is simple. See how it looked:

<?php echo get_permalink( get_option( 'page_for_posts' ) ); ?>

Follow Wordpress Forum link: link

Browser other questions tagged

You are not signed in. Login or sign up in order to post.