【问题标题】:Custom Field not working in value get_the_content?自定义字段在值 get_the_content 中不起作用?
【发布时间】:2023-01-12 18:53:18
【问题描述】:

`

$metadescription = wp_trim_words( get_the_content(), 55, '');

add_post_meta($post_id, 'meta_description', '$metadescription', true);`

但输出是 $meta 描述

任何人请帮助我

`$meta description = wp_trim_words( get_the_content(), 55, '');

add_post_meta($post_id, 'meta description', '$meta description', true);``

【问题讨论】:

    标签: wordpress custom-fields


    【解决方案1】:

    试试下面的代码:

    对于变量,您不需要为此使用 ''

    $metadescription = wp_trim_words( get_the_content(), 55, '');
    
    add_post_meta($post_id, 'meta_description', $metadescription , true);
    

    【讨论】:

    • 不适用于删除 ''
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-06
    • 1970-01-01
    相关资源
    最近更新 更多