尝试将get_the_title钩子添加到此行

时间:2018-06-27 03:19:30

标签: php css wordpress

enter image description here

您好,尝试将get_the_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>';?>
  </div>
</div>

2 个答案:

答案 0 :(得分:0)

如果我理解正确的问题:

<?php echo '<textarea style="margin-left: 15px; width: 246px;" rows="3" cols="28" placeholder="I am interested in:" name="cf-message">I am interested in: ' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : '' ) . '</textarea>';?>

答案 1 :(得分:0)

这是我有效的解决方案:

....placeholder="I am interested in: '.get_the_title().' "....