How to get the current blog’s ID

I have a page name “Blog”, it contains a list of posts.

In Settings->Reading->”Posts page:” I selected “Blog”.

Read More

How can I get the id of the Blog from template.

Related posts

Leave a Reply

2 comments

  1. To get the ID of the page selected in Settings->Reading->”Posts page:” try this line of code:

    $frontpost_id = get_option('page_for_posts');
    
  2. If you got to select “Blog” as the posts page it has to be a page you previously created in the Pages section.

    To get the ID of the current page you simply do a $post->ID before you enter the loop of posts in your page template. First you do a global $post though. Like this:

    <?php
    global $post;
    $current_page_id = $post->ID;
    // Whatever else you're going to do
    ?>