Development,  WordPress

Add meta boxes on Front Page only without template

I am rewriting one of my old pages into WordPress theme and I needed some meta boxes. But for front page only. I don’t need them to be show on any other page. It isn’t very hard to do, you just need to check template meta. But I don’t want to use template. I got front-page.php file to view front page and that’s it, I don’t need specialized template. So, what to do? It’s pretty easy.

First, we need to hook into meta-box action. It’s simple and well known, but… Here’s the code:

Next step is also easy as pie. We need to compare current object ID with page id set as front page. We can do this like this:

Leave a Reply

Your email address will not be published. Required fields are marked *