首页 文章

如何在帖子 Headers 上方添加Wordpress图像缩略图

提问于
浏览
0

试图在我们的主题中编辑帖子页面,并希望在帖子 Headers 上方添加缩略图图像,但它会将缩略图放在帖子 Headers 的末尾 . 任何帮助表示赞赏 .

if (have_posts()) :
                echo "<h1>" . __('Valhalla Integration Blog','avia_framework') . "</h1>";
                echo "<ul>";
                    while (have_posts()) : the_post(); 

                if ( has_post_thumbnail() ) {
                    the_post_thumbnail();
                }

                    echo "<li><h4><a href='".get_permalink()."' rel='bookmark' title='". __('Permanent Link:','avia_framework')." ".the_title_attribute('echo=0')."'>".get_the_title()."</a></h4></li>";

                    endwhile;
                echo "</ul>";
                else:

                  echo "<h3>" . __('No Blog Posts found','avia_framework') . "</h3>";

                endif;

1 回答

  • 2

    您将 <img> 标记回显到 <ul> ,这是无效的HTML . 我修改它以回显 <li> 中的图像,其中也包含您的 Headers .

    if (have_posts()) :
    echo "<h1>" . __('Valhalla Integration Blog','avia_framework') . "</h1>";
    echo "<ul>";
        while (have_posts()) : the_post(); 
    
        echo "<li>";
    
            if ( has_post_thumbnail() ) {
            the_post_thumbnail();
        }
    
        echo "<h4><a href='".get_permalink()."' rel='bookmark' title='". __('Permanent Link:','avia_framework')." ".the_title_attribute('echo=0')."'>".get_the_title()."</a></h4></li>";
    
        endwhile;
    echo "</ul>";
    else:
    
    echo "<h3>" . __('No Blog Posts found','avia_framework') . "</h3>";
    
    endif;
    

相关问题