admin管理员组文章数量:1026073
I am using transition_post_status
hook to add get some data at the time of post is publish but i can access any variables but when i am trying to set canonical url from add_filter
it is return 500 error
// Add the hook action
add_action('transition_post_status', 'send_new_post', 10, 3);
// Listen for publishing of a new post
function send_new_post($new_status, $old_status, $post) {
if('publish' === $new_status && $post->post_type === 'post') {
print_r('this is done');
$post_meta = get_post_meta($post->ID, '', true);
$object_id = $post_meta['mydo_post_id'][0];
$canonical_url = '/'.$object_id;
add_filter( 'wpseo_canonical', 'add_canonical' );
function add_canonical($url){
return $canonical_url;
}
}
}
Above is my code i am using can anyone help?
I am using transition_post_status
hook to add get some data at the time of post is publish but i can access any variables but when i am trying to set canonical url from add_filter
it is return 500 error
// Add the hook action
add_action('transition_post_status', 'send_new_post', 10, 3);
// Listen for publishing of a new post
function send_new_post($new_status, $old_status, $post) {
if('publish' === $new_status && $post->post_type === 'post') {
print_r('this is done');
$post_meta = get_post_meta($post->ID, '', true);
$object_id = $post_meta['mydo_post_id'][0];
$canonical_url = '/'.$object_id;
add_filter( 'wpseo_canonical', 'add_canonical' );
function add_canonical($url){
return $canonical_url;
}
}
}
Above is my code i am using can anyone help?
本文标签: adding wordpress yoast SEO canonical url from quottransitionpoststatusquot hook
版权声明:本文标题:adding wordpress yoast SEO canonical url from "transition_post_status" hook 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745625819a2159853.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论