Plugin Author
scribu
(@scribu)
If you’re able to edit them in the backend, you should be able to edit them on the front-end as well.
Please paste your CPT definition code.
Here’s the code. I am trying to make a table that can be edited:
[Code moderated as per the Forum Rules. Please use the pastebin]
On the live page the cell with content outputted by the_title() and the_terms() cannot be edited, however, the content output with editable_post_meta() can be.
Thanks for your help.
Plugin Author
scribu
(@scribu)
Ok, but I meant the register_post_type( ... ) code.
If you don’t have something like that, add the following code after the code you just posted and paste the results:
<pre>
<?php print_r( get_post_type_object( 'deal' ) ); ?>
</pre>
Ah, sorry for the confusion. Here is the code from functions.php:
[Code moderated as per the Forum Rules. Please use the pastebin]
Sorry about that. Here is the code to initialize the custom post type: http://pastebin.com/n5iazLwM
Here is the output of your request: http://pastebin.com/TzLv2KB1
Plugin Author
scribu
(@scribu)
I’ve added that code to my local install and it works fine.
Try disabling all other plugins. Then, try swithching to the default theme.
Hi, scribu,
I have tinkered around with this. I tried deactivating all other plugins and then registering the same post type in the custom theme, but I am still unable to edit the title, or any of the custom taxonomy fields when I display the custom post_types. I tried this in the default theme.
Am I calling back the fields imporperly?
<?php the_title(); ?>
<?php the_terms($post->ID, 'industry'); ?>
<?php the_terms($post->ID, 'source'); ?>
<?php the_terms($post->ID, 'location'); ?>
the_title(); call is editable when I am looking at it inside the regular loop. The only think I can think is that something is going awry when I register the custom post type. I am using the ‘capability_type’ => ‘post’ argument. Should I be listing something else in the ‘capabilities’ array?
Thank you again for your help. Oh, and thank you for catching that bug about evaluating custom fields with 0 values. That was killing me π
Plugin Author
scribu
(@scribu)
All those fields will only be editable if you’re in The Loop.
Specifically, in_the_loop() has to return true.
Bingo, that seems to be the issue. I am calling a custom WP_Query:
$args = array(
'post_type' => 'deal',
'post_status' => 'publish',
'orderby' => 'date'
);
$deals = new WP_Query($args);
if ($deals->have_posts()) :
while ($deals->have_posts()) :
$deals->the_post();
The fields aren’t edible when I do just that. It looks like WordPress does not consider me to be in the loop, i.e, (in_the_loop() returns false. Luckily, I can manually adjust this with:
<?php $wp_query->in_the_loop = true; ?>
Thanks for helping me troubleshoot.
Plugin Author
scribu
(@scribu)
Glad to hear you figured it out.
I have to make that check in order to prevent titles in menus from being editable etc.