0

I used to have an archive-rooms.php (as page-rooms.php) template to list them all

This had few problems:

  • No title page
  • No way to synch menu item with title

so:

1) I duplicated the archive-rooms and prepended to it:

<?php
/*
Template Name: Rooms Template
*/
?>

2) Created page, assigned the template and set the slug from the post type to the page
3) Removed has_archive from the register_post_type() arguments

Now the problem, when I open the page the content is not what I expected, expecially the class of the body:

<body class="blog">

Which something like this I was expecting:

<body class="page page-id-xx page-template-rooms etc..">

Any explanation/suggestion for this issue?

Thanks

  • In wp-admin, go to Settings > Reading. If "Posts page" is set to the page you have just created, that is why it is adding "blog" to the body class. If you don't have a generic post archive but do have a customized front-page.php it is safe to leave "Your homepage displays" set to "Your latest posts" and that also will keep WP from adding the "blog" class to the Page. – WebElaine Nov 26 '18 at 16:24
  • did you change the name of your copied php from archive-rooms.php to template-rooms.php? – rudtek Nov 26 '18 at 17:56
  • @rudtek no, like I said. I duplicated the file with page-rooms.php ( archive-rooms.php still exist. I tried deleting but same result ) – Toni Michel Caubet Nov 26 '18 at 18:40
  • Try renaming it to template-rooms.php – rudtek Nov 26 '18 at 19:16
  • How Do you think it would help ( which file, by the way ) ? – Toni Michel Caubet Nov 26 '18 at 19:20

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.