@tobys Unfortunately we can’t offer support on custom code. Since we don’t want to take the risk that we break your website by suggesting incorrect or incomplete code, we cannot advise you on how to make such changes. Maybe someone watching these forums can assist you further, but if your topic is inactive for 7 days, we’ll mark it as resolved to keep the overview.
Thread Starter
Tobys
(@tobys)
For anyone curious, this is the solution I came up with. If anyone can spot weaknesses or a better solution, then please let me know.
<?php
use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
function remove_wp_seo_presenters( $filter ) {
if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter', $filter)) !== false) {
unset($filter[$key]);
}
return $filter;
}
add_filter( 'wpseo_frontend_presenter_classes', 'remove_wp_seo_presenters' );
class Custom_Presenter extends Abstract_Indexable_Presenter {
public $property;
public $content;
function __construct($property, $content) {
$this->property = $property;
$this->content = $content;
}
public function present() {
return '<meta property="' . esc_attr( $this->property ) . '" content="' . esc_attr( $this->content ) . '" />';
}
public function get() {
return null;
}
}
function add_custom_presenter( $presenters ) {
$modified_time = new Custom_Presenter("article:modified_time", "2020-11-10");
$presenters[] = $modified_time;
return $presenters;
}
add_filter( 'wpseo_frontend_presenters', 'add_custom_presenter' );
?>
<?php
use Yoast\WP\SEO\Presenters\Abstract_Indexable_Presenter;
function remove_wp_seo_presenters( $filter ) {
if (($key = array_search('Yoast\WP\SEO\Presenters\Open_Graph\Article_Modified_Time_Presenter', $filter)) !== false) {
unset($filter[$key]);
}
return $filter;
}
add_filter( 'wpseo_frontend_presenter_classes', 'remove_wp_seo_presenters' );
class Custom_Presenter extends Abstract_Indexable_Presenter {
public $property;
public $content;
function __construct($property, $content) {
$this->property = $property;
$this->content = $content;
}
public function present() {
return '<meta property="' . esc_attr( $this->property ) . '" content="' . esc_attr( $this->content ) . '" />';
}
public function get() {
return null;
}
}
https://casinoshunter.com/online-casinos/roulette/
function add_custom_presenter( $presenters ) {
$modified_time = new Custom_Presenter("article:modified_time", "2020-11-10");
$presenters[] = $modified_time;
return $presenters;
}
add_filter( 'wpseo_frontend_presenters', 'add_custom_presenter' );
?>
Expand
Perfect