We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
Idea
class Play extends Abstract_Schema_Piece { /** * A value object with context variables. * * @var WPSEO_Schema_Context */ public $context; /** * Play constructor. * * @param WPSEO_Schema_Context $context Value object with context variables. */ public function __construct( WPSEO_Schema_Context $context ) { $this->context = $context; } /** * Determines whether or not a piece should be added to the graph. * * @return bool Whether or not a piece should be added. */ public function is_needed() { // Check if the current context requires a play schema return $this->context->indexable->object_type === 'play'; } /** * Add Play piece of the graph. * * @return mixed */ public function generate() { // Retrieve play data from context or other source $play_title = $this->context->post->post_title; $play_description = $this->context->post->post_content; $play_author = get_post_meta( $this->context->post->ID, 'play_author', true ); $play_director = get_post_meta( $this->context->post->ID, 'play_director', true ); $play_duration = get_post_meta( $this->context->post->ID, 'play_duration', true ); $play_start_date = get_post_meta( $this->context->post->ID, 'play_start_date', true ); $play_end_date = get_post_meta( $this->context->post->ID, 'play_end_date', true ); $play_venue = get_post_meta( $this->context->post->ID, 'play_venue', true ); // Construct play schema $play_schema = array( '@type' => 'Play', 'name' => $play_title, 'description' => $play_description, 'author' => $play_author, 'director' => $play_director, 'duration' => $play_duration, 'startDate' => $play_start_date, 'endDate' => $play_end_date, 'location' => array( '@type' => 'Place', 'name' => $play_venue ) ); return $play_schema; } }
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: