Discourse_publish_format_html -> rewrite topic title?

I’ve searched around and am not seeing anything specific about this. I can successfully grab and display custom fields when posting to Discourse from Wordpress as part of the topic “content” and create different templates according to post type, but is it possible to use a custom field to rewrite the Discourse topic title? Such as appending a formatted date field to an “event” title when it gets posted to Discourse?

1 Like

Try hooking into the wpdc_publish_format_title filter. It’s passed two arguments: $title and $post_id.

Something like this should work:

add_filter( 'wpdc_publish_format_title', 'wpdc_custom_publish_format_title', 10, 2 );
function wpdc_custom_publish_format_title( $title, $post_id ) {
    if ( get_post_meta( $post_id, 'your_meta_key', true ) ) {
        // Modify $title here.
    }

    return $title;
}
3 Likes

I will try this out as soon as I can, thank you for the pointer!

1 Like

Works great! This has the same field data save timing issues as displaying custom fields in the content when auto-publishing is enabled but the titles update as expected with this lag in mind. Thanks!

1 Like

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