Print dynamically URL of posts page in WordPress

0

How do I make a echo in the posts page URL when WordPress is set to display a page like Homepage and the posts on a specific page? For example:

Under Settings > Reading You can 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. Home Example: echo pegue_a_pagina_de_posts(); . Home Result: link
obs .: this was just an example. Of course this function does not exist :)


I'm developing a theme, so there is no other option. I need to dynamically select posts URL.

    
asked by anonymous 24.10.2017 / 16:20

1 answer

1

I found the answer. I asked the same question in the official WordPress forum and I was given the following answer:

get_option( 'page_for_posts' );

The above code returns the post page ID. Getting the URL is straightforward. Here's how it went:

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

Follow the link from the WordPress Forum: link

    
25.10.2017 / 15:46