I am trying to find the ID of my posts page (the dynamic page that always displays the latest post on top). I found out that I need to include this code in index.php:

$page_for_posts = get_option( 'page_for_posts' ); 

(I work with a child theme of TwentyEleven which has no home.php or front-page.php). I am a total beginner. Please could someone post a bit more code from index.php that makes it clear to me where the above snippet needs to be inserted? Is index.php even correct?

  • That code snippet need to be inserted where you need it; not sure what you are asking about. What are you trying to do exactly? – cybmeta Sep 22 '17 at 9:32
  • You can find the post id of the post by editing the post it will be displayed on the address bar – Pratik bhatt Sep 22 '17 at 10:24
  • @Pratik bhatt: the ID that is displayed when I do that doesn't seem to "work". When I try to edit something using that ID, nothing happens, whereas the same thing works when I use i.e. .home (or another site's ID) instead of that ID. – Anne Morbach Sep 22 '17 at 13:21
  • @cybmeta: I would like to edit something only on that page using custom CSS. Normally, the page ID is displayed in the inspector in Firefox under <body class=..., but not for the posts page. – Anne Morbach Sep 22 '17 at 13:22
  • Are you using multisite? – Pratik bhatt Sep 22 '17 at 13:41

Your Answer

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

Browse other questions tagged or ask your own question.