开发者

WordPress page is listed in "Posts" but appears on site as a "Page", What gives?

开发者 https://www.devze.com 2022-12-23 02:56 出处:网络
I\'ve seen this on a few sites now and its puzzling me. The page will be listed under the \"Edit Posts\" listing, however, when I click on \"View Page\" to see the live post, its being served out as a

I've seen this on a few sites now and its puzzling me. The page will be listed under the "Edit Posts" listing, however, when I click on "View Page" to see the live post, its being served out as a 开发者_开发知识库"Page". I can tell this by viewing the source and the body tag is...

<body class="page page-id-37 logged-in"> 

If its were actually a post, the body tag should be

<body class="single postid-63 logged-in"> 

I've seen a "post to page" and a "page to post" plugin that will convert between pages and posts, however, this site has NO plugins other than the wordpress defaults (akismet and hello dolly).

I'm stumped.


Well I found the answer with a little more digging. Here's what's happened:

The site owner had originally created this post as a "Page". He then deleted this "page" and re-created it as a "post" with the same post slug as the one he had deleted.

As long as the deleted page had the same post slug as the new "post", Wordpress was presenting the content in the "page.php" template and not the single.php template.

The only way I could get it to work was to go to the Page's Trash listing and click "delete permanently" on the original page.


your may read this on body class functon, this function usually used by theme developer. It directly output class according to theme developer input. It seem the theme developer only use one file (page.php) to show page and post. (and it's better approach to create single.php to show a post).

So, the output will be like you describe.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号