Get blog page URL in WordPress

If you are working on some kind of customizations or developing some kind of theme or plugin in thing in WordPress you must have to read this. here we will discuss how WordPress get blog page permalink works.

WordPress development is made easy for developers due to its built-in functions. If you want to know how to get the blog page URL in WordPress this article is for you.

Details of wordpress get blog page permalink function:

In simple words, this function is used to get the URL or permalinks of one WordPress post to another post.

Syntax:

get_blog_permalink( int $blog_id, int $post_id ): string

in PHP it is written as:

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

Parameters

$blog_id int Required

ID of the source blog.$post_id int Required

ID of the desired post.


Return

string The post’s permalink

Read more about this here.

Example:

function get_blog_permalink( $blog_id, $post_id ) {
	switch_to_blog( $blog_id );
	$link = get_permalink( $post_id );
	restore_current_blog();

	return $link;
}

Read more: How to Choose a hosting provider smartly?

How to get a post title in WordPress?

Leave a Reply