commit 3dd4aa672240213094cd6086c26000d4da3f5201 Author: David Madl Date: Sun Mar 1 19:44:45 2026 +0100 initial: skeleton plugin diff --git a/ruady-og-head.php b/ruady-og-head.php new file mode 100644 index 0000000..88259e9 --- /dev/null +++ b/ruady-og-head.php @@ -0,0 +1,103 @@ + for the currently displayed singular object. + */ + public static function render_head_markup(): void { + // Adjust this if you only want standard posts: + // if ( ! is_singular( 'post' ) ) { return; } + if ( ! is_singular() ) { + return; + } + + $post_id = get_queried_object_id(); + if ( ! $post_id ) { + return; + } + + $post = get_post( $post_id ); + if ( ! $post instanceof WP_Post ) { + return; + } + + $html = self::build_markup_for_post( $post ); + + if ( $html === '' ) { + return; + } + + echo "\n" . $html . "\n"; + } + + /** + * Build the head markup for one post. + * + * This is the function you will customize. + */ + private static function build_markup_for_post( WP_Post $post ): string { + // Example 1: conditionally emit markup only for a specific post type. + if ( $post->post_type !== 'post' ) { + return ''; + } + + $post_url = get_permalink( $post ); + $post_title = get_the_title( $post ); + $excerpt = has_excerpt( $post ) ? get_the_excerpt( $post ) : ''; + + // Example business logic: + // - add a meta tag for every post + // - add JSON-LD only if the post is in category "news" + $is_news = has_category( 'news', $post ); + + ob_start(); + ?> + + + + + + + + + + + + +