I’m trying to include the featured image of my wordpress post to be displayed in the Discourse linked topic. Ideally it would show above all the other post content (regardless on whether or not “show full post”/truncation is turned on or not). Any suggestions would be greatly appreciated!
Alright, I tried to get that to work but I was thrown a PHP error. (unexpected < somewhere). I was able to add your other suggestion perfectly fine, Clearing the text from the shortcode - #5 by Del33t, but not when including the featured image. I imagine I’m copy+pasting too many things or the wrong things into my function.php file. I’m honestly confused with the majority of the following paragraph:
This can be done in a custom template by copy and pasting the publish_format_html() function from it’s github, renaming the function by adding a namespace, adding the {featuredimage} template tag, removing the call to apply_filters from the function’s return statement, and then hooking into the new function. Note: you also need to remove the self::get_text_options() statement from the original function.
And then additionally confused by the code you’ve added following it.
My function.php file is super simple at the moment:
I’m not sure, but it looks like there is a problem with the regular expression in the preg_replace statement. Try: $excerpt = preg_replace( '/\[.*\]/', '', $excerpt );
The best way to work things like this out is to do your development in a local development environment and figure out how to log the output so you can see what’s going on. (You can still connect to a remote Discourse forum. Just publish your posts to a private category.)
Getting too involved with basic PHP programming is probably outside of the scope of this forum. If you’re really stuck, send me a message and I’ll see if I can help.