"Edit" option for custom post types archive page

admin2025-06-02  5

I have a custom post type archive page but I also need the user to be able to insert a bit of page text. I thought I could just use the_content() of the page but the edit link is gone from the admin menu for custom post types archive pages.

Is this something new and is there any way to enable it?

I have a custom post type archive page but I also need the user to be able to insert a bit of page text. I thought I could just use the_content() of the page but the edit link is gone from the admin menu for custom post types archive pages.

Is this something new and is there any way to enable it?

Share Improve this question edited Jun 15, 2020 at 8:21 CommunityBot 1 asked May 12, 2015 at 19:29 The Digital NinjaThe Digital Ninja 1331 silver badge5 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6

I'm not sure if I understand you correctly, but maybe this will help you.

If you're on CPT archive, then there is no "Edit" link, because it's archive and not a page... Archive is list of posts, so there is no single post to edit... Another example of archive page is when you're viewing search results or all posts from given year - there is nothing to edit in these views.

What you can do/how would I do it?

You can add new page and set its slug to the same value as CPT slug...

Let's say your CPT is 'Book' with slug 'book'. You can add normal page called 'Book' with slug 'book'.

CPT archive and single CPT has higher priority than single page in Rewrite Rules, so this page will be ignored by WP. But you can manually display it's content in archive-book.php template...

You can achieve this by including the following in your CPT archive:

<?php
$page_id=12; // Add id of the page
$post = get_post($page_id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
?>
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748878939a314479.html

最新回复(0)