亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Wordpress - 在 echo -html 文本框中寫入 <?php ?>

Wordpress - 在 echo -html 文本框中寫入 <?php ?>

PHP
神不在的星期二 2022-07-09 10:58:42
我需要將元值從 db 檢索到我創建的自定義元框。這是我的代碼。 function wpl_owt_book_function( $book ) {    define("_FILE_", "_FILE_");    wp_nonce_field( basename(_FILE_), "wp_owt_cpt_nonce");    echo "<label for='txtPublisherName'>Publisher Name</label>";    $publisher_name = get_post_meta($post->ID, "book_publisher_name" , true);    echo "<input type ='text' name = 'txtPublisherName' value = '<?php $publisher_name; ?>' placeholder = 'Publisher Name' />";}文本框的結果輸出使占位符成為<?php文本框和文本框之外") placeholder = 'Publisher Name' />"任何人都可以調查這個問題并給我一個解決方案!祝你有美好的一天!
查看完整描述

2 回答

?
達令說

TA貢獻1821條經驗 獲得超6個贊

你已經在 PHP 中了,所以改變這個:

echo "<input type ='text' name = 'txtPublisherName' value = '<?php $publisher_name; ?>' placeholder = 'Publisher Name' />";

至此?。▌h除 PHP 標簽)

echo "<input type ='text' name = 'txtPublisherName' value = '" . $publisher_name . "' placeholder = 'Publisher Name' />";



查看完整回答
反對 回復 2022-07-09
?
人到中年有點甜

TA貢獻1895條經驗 獲得超7個贊

您需要將 $post->ID 替換為 get_the_ID()。所以,更換

get_post_meta($post->ID, "book_publisher_name" , true);

get_post_meta(get_the_ID(), "book_publisher_name" , true);

并替換

echo "<input type ='text' name = 'txtPublisherName' value = '<?php $publisher_name; ?>' placeholder = 'Publisher Name' />";

echo "<input type ='text' name = 'txtPublisherName' value = '".$publisher_name."' placeholder = 'Publisher Name' />";



查看完整回答
反對 回復 2022-07-09
  • 2 回答
  • 0 關注
  • 148 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號