编码HTML内部PHP


Coding HTML inner PHP

我想这样做:

<a href="...">
<img src="..." />
<h5>Older Post</h5>
<p>Titel</p>
</a>

我的代码

<?php next_post_link('%link', "$prevthumbnail __('<h5>Older Post</h5>'), 
<p>%title</p>", TRUE); ?>

但根本不起作用。我在结合PHP(WordPress翻译)和HTML:时遇到了一些语法问题

感谢您的帮助
Ogni

---更新---

<?php next_post_link('%link', "$nextthumbnail", TRUE); ?>
<?php next_post_link('%link', __("<span class='header'>Older post</span>", "SCNR"), TRUE); ?>
<?php next_post_link('%link', "<span>%title</span>", TRUE); ?>

这是未经测试的,但它应该能满足您的需求。我们没有使用next_post_link()函数来构建更简单的链接,而是自己构建链接。

<?php
// Gets the ID of the next post in the same term
$next_post = get_next_post( true );
// If that ID exists...
if ( ! empty( $next_post ) ) :
?>
  <a href="<?php echo get_permalink( $next_post ); ?>">
    <?php echo get_the_post_thumbnail( $next_post ); ?>
    <h5><?php _e( 'Older Post', 'textdomain' ); ?></h5>
    <p><?php echo get_the_title( $next_post ); ?></p>
  </a>
<?php endif; ?>

如果您需要一些认真的帮助,请尝试一下。

<?php
   //connect to database and set variables or whatever
   $link = "http://foo.bar";
   $prevthumbnail = "img/foo.png";
   $title = "The Foo Bar";
   //then print this...
   echo '<a href="'.$link.'"><img src="'.$prevthumbnail.'" /><h5>Older Post</h5><p>'.$title.'</p></a>';
?>