Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #430797

    I have two custom post types and I wanted to show the featured image on the “all posts” page in the admin for both CPTs. The first one is “agents” and the second one is “commercial-sale”. For agents, I have to add these two lines of code to my plugin to show the featured image:

    add_filter("manage_edit-agents_columns", "post_edit_columns");
    add_action("manage_agents_posts_custom_column",  "prod_custom_columns");

    If I omit either of these lines, the preview image will not show up.

    For the “commercial-sale” CPT I added similar lines of code to to my plugin:

    add_filter("manage_edit-commercial-lease_columns", "post_edit_columns");
    add_action("manage_commercial-lease_posts_custom_column",  "prod_custom_columns");

    But doing this makes the preview image show up twice. If I comment out only the FIRST line, I don’t get any preview image at all. If I comment out only the SECOND line, then I get a single preview image just like I would get for the agents CPT.

    Can you help me understand what’s going on here?

    Thanks!

    #431441

    Hi Kevin!

    This isn’t really a theme question. It would be best to ask on the WordPress support forums, https://wordpress.org/support/.

    And be sure to read this, https://codex.wordpress.org/Function_Reference/register_post_type.

    Cheers!
    Elliott

    #432040

    Thanks, Elliott. I assumed it was an issue with the functions being called on the filter and action but I’ll look into it more elsewhere.

    Was there a specific reason you suggested reading up on register_post_type? I’m pretty familiar with that function but I’m not seeing how it’s related to this issue. Other than the fact that this is where you add featured image support, I’m not sure how it relates to my question.

    Thanks!

    #432913

    Hey!

    It’s just so you understand how to create CPT’s. For example the supports > thumbnail option needs to be set if you want the featured image option to be available.

    Regards,
    Elliott

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.