plugin development – Showing Home option in dropdown when there is no Home page exist


I am developing a plugin and in the admin side, I need to show a dropdown with options of all types of pages and posts etc. Its kind of a visibility option for a widget to be displayed on pages selected by users.

Now I have three main sections:

  • Posts (auto-fill all posts when typing)
  • Pages (auto-fill all pages when typing)
  • Categories

In each section above, the admin can target where the widget/component should be displayed.

My question is:

How to include the home page in the above section when the default home page is showing Posts and not any custom static page? What is actually home page ID in that case? When I print get_option('page_on_front'); or get_the_ID(); both return latest post ID on the home page. Why is it like that?

iZeshan 6 days 2023-03-17T02:06:55-05:00 0 Answers 0 views 0

Leave an answer