Discourse Publishing Link for Custom Post Type Disappears

Hello,

The Discourse publish feature does create a topic for a custom post type, however, the link doesn’t appear in wp-admin. I have checked in the WordPress database under post_meta, and the “discourse_permalink” key for that post exists, but for some reason the link doesn’t show up.

I created the custom post type with Meta Box. This seems to be an issue with custom post types specifically. The default WP posts work fine and show the link in wp-admin.

Thank you!

Jacob Hill

Hey Jacob :slight_smile:

Could you confirm a few things for me.

  1. Your custom post type is selected in the WP Discourse “Publishing” setting “Post Types to Publish”?

  2. When you say “the link doesn’t appear in wp-admin” you mean the link is not appearing here?

1 Like

Hi Angus! Yes to both of your questions.

Regarding question 2, it acts as if there was no link and allows me to publish a new post, or link to the topic. If I publish or link, result is the same - the interface from your screenshot shows no link, although it appears in the DB under post_meta for that post.

Thanks for the help!

Ok, I’ll attempt to re-create this issue later this week.

In the meantime if there are any PHP logs for your instance you can share, that would be helpful. Also take a look at the WP Discourse logs for any hints.

Hi @angus, thank you!

I did more research on this issue, I don’t have a solution, and there were no logs generated that I could locate. Here is the info:

After publishing the topic to Discourse, this appears in the DB for that post which looks correct.

The topic appears in Discourse fine, but the wp-admin post edit interface acts as if this wasn’t ever done, even though the entries are in the DB:

When I try linking the same post, the DB entries are updated, and I get the following message, but it shows no link after a refresh:

image

After linking, the DB looks like this:

image

I’m unsure why this isn’t working with custom post types. Like I said, it is working fine for the default posts.

Hope that helps!

Jake

Hi @angus just checking in for an update on this one. :slight_smile: Thank you!

I’m unable to recreate this at the moment. Could you send me the “metafile” in the WP Discourse logs panel?

Hi @angus can you tell me how to get the metafile for you?

Something interesting, the comments do show up on the front end, so the link that appears in the DB is working, however it does not show in wp-admin.

When you download the logs the zipped folder will include the metafile. You can PM it to me here.

Are you sure there are no logs for your Wordpress instance more broadly? My gut says that there’s some kind of exception occurring that is preventing the sidebar logic from working properly. Could you try this for me:

  1. When editing a post where you see the issue occuring
  2. Open your browser console (instructions for different browsers)
  3. Reload the page and take a screenshot of any logs that appear in the browser console.

Hi @angus I’m sorry for the delay, I thought you were talking about the logs in Discourse, I realize now you are wanting the WordPress plugin’s logs. :slight_smile:

I’ve sent you the files! I actually tested disabling all plugins except for the ones below and reverting to the 2023 theme as well, and the same issue persists. No logs related to this issue, same as before.

It seems to be an issue related to the custom post type, perhaps specific to the CPT that is created tby MetaBox.

Your issue is not with the WP Discourse plugin. You need to enable custom-fields support in the code that registers the Meta Box custom post types you’re using. The WP Discourse sidebar will then work as expected.

your_prefix_register_post_type() {
  ...
  $args = [
     ...
     'supports' => ['title', 'editor', 'thumbnail', 'custom-fields']
  ]
}
2 Likes

Hi @angus that did the trick, thanks very much!! I ticked the “Custom Fields” box in the Meta Box CPT settings, and now the link shows up in the wp-admin editor!

image

Thank you very much for the help!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.