3

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?

admin bar

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...

  • Are you sure this works or I might be missing something? I'm using the_content() inside of my archive-authors.php file and it doesn't display me the WISYWIG content from my /authors page. – elvismdev Nov 9 '16 at 9:56
  • Of course it doesn't display, because the page isn't loaded? Why should it be? As I've written in my answer, the CPT has higher priority than page, so WP will display the CPT and not this page. If you want to display this page's content, then you have to load it yourself and display it's content... – Krzysiek Dróżdż Nov 9 '16 at 12:24
  • There needs to be a way to manage basic content atleast on archive pages. As sites are growing, technology needs to grow here with it. ALL pages need to have content that is manageable in any CMS. This is not Rocket Science! If it's a url, it needs to have content that is managed! Thus "Content Management System (CMS)" – Solomon Closson Nov 11 '17 at 0:11
0

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;
?>
  • This would allow the OP to edit a page's content that would then be included in the CPT archive, yes, but it still won't add an Edit button to the CPT archive page itself. (Also, it requires that you hard-code the page's ID in the template file, which is pretty limiting.) – Pat J Apr 24 '18 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.