I’m writing because I’m noticing a strange behavior with Poster 2 (2.9.2) in RapidWeaver Classic using the Source theme, a Freestyle Template, and PHP Enabler (with Inject SEO Metadata enabled and social tag generation disabled in RapidWeaver).
I noticed that when I place the PHP Enabler stack (even empty, with nothing inside) inside the Main Content of a single post, the <meta property="og:image" content="..."> tags (along with the other Open Graph/Twitter meta tags and the NewsArticle schema) disappear from the <head> of the single post page (?post=...), leaving the generic <title> and <meta name="description"> of the page, and they only reappear if I remove the PHP Enabler stack (even after republishing with an updated rwcache and with only index.php on the server).
I’d like to ask if I can use PHP Enabler without running into this issue.
My use case is simple: inside the Main Content of a single post (dedicated to an EPUB), I added a small PHP script that fetches and displays updated reviews from Apple Books (saving the data to a local file cache). Later on, I will also need to add more of these for audiobooks and other EPUBs.
So I need to be able to run this small PHP block inside individual posts without losing — which is essential for me — the Open Graph/Twitter meta tags and the NewsArticle schema generated by Poster 2 in the <head>.
Is there a recommended way to run PHP code inside a single post in Poster 2 without running into this issue?
Yeah, just don’t run PHP code inside a post. It’s just not ment to be.
The best way would be to get this data differently. Like calling the PHP script with a JavaScript Ajax call asynchronously, and display the data inside the post would be the best way to do so.
That’s actually the exact approach I was planning to take: keeping PHP out of the post content, putting the PHP script in a separate endpoint with file caching, and loading it asynchronously via fetch into a container inside the post so Poster 2’s <head> metadata stays intact.
This will then also work with Poster 3 markdown editor.
You could also add just add div tag with data attributes into the main content area, and a script running on DOMContentLoaded to check for content it has to replace.
Just a quick update to let you know that moving the PHP logic to an external endpoint loaded asynchronously solved everything—Poster 2’s <head> and Open Graph tags are super clean now and everything is working great.
While I was at it, I ran a check on Google’s Rich Results Test and noticed one small non-critical suggestion in the NewsArticle schema: Google recommends adding an optional "url" field inside author (like a link to the author’s homepage or bio page).
Since Poster 2 currently only has fields for Author and Co-Author names, here’s a quick idea for Poster 3: would you consider adding an optional Author URL (and maybe Co-Author URL) field so it automatically fills in "url" in the structured data?