Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator t-p

    (@t-p)

    wordpress won’t let me choose those pages as a static homepage

    If you intend to create/use a static/front page, please review this documentation article: https://ww.wp.xz.cn/documentation/article/create-a-static-front-page/

    • This reply was modified 1 year, 2 months ago by t-p.
    Thread Starter valeriewilcox

    (@valeriewilcox)

    thank you for your reply.

    The problem is that the “portfolio” pages don’t show up, in that dropdown menu, when selecting the front page.

    Moderator bcworkz

    (@bcworkz)

    That page looks like a custom post type, which is why it does not appear in the page list. It’s a little tricky getting a CPT appear as a front page. You essentially need to make a custom page template that loads the CPT. First create two new pages. One for the front page and one for the blog page, even if you do not use the blog feature. Choose titles that you’ll readily recognize as your front and blog page. Titles needn’t display on the front end, it’s just for reference. It also does not need any specific content, but it could if you wanted to use it.

    Determine what template is used to display the portfolio page. There are plugins like Template Debugger that can help you. Make a copy of the template and rename it front-page.php (if one already exists, rename it as well as a backup).

    Set your site to have a static front page and chose the home and blog pages you created.

    A normal front page query will get the page you’ve created. We now need to alter this so it instead returns your portfolio page. This is best done through the “pre_get_posts” action hook. If is_front_page() returns false, don’t change anything, it’s the wrong query. If true is returned, unset the page_id query var, we don’t want it. Instead set the “p” query var to the ID of your CPT. Also set the “post_type” query var to be that for your CPT (“portfolio”?).

    This should return the correct CPT and display correctly as the front page. There are a lot of elements that need to come together for this to work, so don’t be surprised if it doesn’t work first try. Something may need massaging to get things working correctly.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to make a portfolio page the homepage’ is closed to new replies.