drls2738 2017-06-22 05:13
浏览 50

在为meta field SEO Yoast管理面板创建的自定义变量的预览中显示内容

I want to show post description as meta description on frontend.For this i created custom variable that will show post desction on frontend.

Here is the code which i am using to create custom variable and is working fine:

function retrieve_var1_replacement( $var1 ) {
    global $post;
    return strip_tags(substr($post->post_content, 0, 150));
}
function register_my_plugin_extra_replacements() {
    wpseo_register_var_replacement( '%%mycustomdesc%%', 'retrieve_var1_replacement', 'advanced', 'This is to show post description' );
}
add_action( 'wpseo_register_extra_replacements', 'register_my_plugin_extra_replacements' );

This code working fine on frontend but the issue is that on post page in admin panel, instead of showing description, its show %%mycustomdesc%% in the snippet preview box. It should show the same content that is coming on frontend.

Here is the backend screenshot for better understanding

enter image description here

Anyone can suggest me how i can show description in place of

%%mycustomdesc%%

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类