您好,创建联系人表单。
正在尝试将get\\u the\\u title()添加到此代码行中:
<?php echo \'<textarea style="margin-left: 15px; width: 246px;" rows="3" cols="28" placeholder="I am interested in:" name="cf-message">\' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : \'\' ) . \'</textarea>\';?>
以下是完整的表单代码:
<div class="col-sm-4">
<div style="height: 400px; width: 300px; background-color: #f8f8f8; border: 1px solid #dddddd;">
<?php echo \'<form action="\' . esc_url( $_SERVER[\'REQUEST_URI\'] ) . \'" method="post">\';?>
<?php echo \'<h5>\';?>
<?php echo \'Ask a question <br/>\';?>
<?php echo \'</h5>\';?>
<?php echo \'<p>\';?>
<?php echo \'<input style="margin-left: 15px;" type="text" placeholder="Your Name (required)" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="\' . ( isset( $_POST["cf-name"] ) ? esc_attr( $_POST["cf-name"] ) : \'\' ) . \'" size="29" />\';?>
<?php echo \'</p>\';?>
<?php echo \'<p>\';?>
<?php echo \'<input style="margin-left: 15px;" type="email" placeholder="E-mail (required)" name="cf-email" value="\' . ( isset( $_POST["cf-email"] ) ? esc_attr( $_POST["cf-email"] ) : \'\' ) . \'" size="29" />\';?>
<?php echo \'</p>\';?>
<?php echo \'<p>\';?>
<?php echo \'<input style="margin-left: 15px;" type="text" placeholder="Phone (required)" name="cf-subject" pattern="[a-zA-Z ]+" value="\' . ( isset( $_POST["cf-subject"] ) ? esc_attr( $_POST["cf-subject"] ) : \'\' ) . \'" size="29" />\';?>
<?php echo \'</p>\';?>
<?php echo \'<p>\';?>
<?php echo \'<textarea style="margin-left: 15px; width: 246px;" rows="3" cols="28" placeholder="I am interested in: " name="cf-message">\' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : \'\' ) . \'</textarea>\';?>
<?php echo \'</p>\';?>
<?php echo \'<p><input type="submit" name="cf-submitted" value="Contact Agent" style="border-radius: 5px; color: #fff; margin-left: 15px; width: 247px; height: 38px; background-color: #27ae60;"></p>\';?>
<?php echo \'</form>\';?>
<?php echo \'<p style="font-size: x-small; font-weight: bold; margin-left: 22px;">\';?>
<?php echo \'By sending a request you agree to our Privacy Policy\';?>
<?php echo \'</p>\';?>
以下是我正在努力实现的目标:
“我感兴趣:”正在显示,并且很容易被占位符调用=“我感兴趣:。我还想将此表单显示在默认占位符后面的帖子标题称为“我感兴趣:”如我添加的图片中所示。突出显示的文本是正在获取的帖子标题。
这是你可以在网上看到的链接http://teamambrose.realtor/property/mls-t3110937-9313-mandrake-ct-tampa-fl-33647/
最合适的回答,由SO网友:anmari 整理而成
乔,你试过了吗
....placeholder="I am interested in: \'.get_the_title().\' "....
此外,您不需要所有这些php。代码可以更干净,更易于阅读。可以执行以下任一操作:
<?php
echo \'<form action="\' . esc_url( $_SERVER[\'REQUEST_URI\'] ) . \'" method="post">\';
echo \'<h5>\';
echo \'Ask a question <br/>\';
?>
等
或
<form action="<?php echo esc_url( $_SERVER[\'REQUEST_URI\'] );>" method="post">
<h5>Ask a question </h5>