如何使用get_content WordPress函数?

如何使用get_content WordPress函数?,wordpress,Wordpress,使用内容WordPress函数时,我无法获取内容 <!-- Start the Loop. --> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( in_category( '3' ) ) : ?> <div class="post-cat-three"> <?php else

使用内容WordPress函数时,我无法获取内容

 <!-- Start the Loop. -->
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category( '3' ) ) : ?>
        <div class="post-cat-three">
    <?php else : ?>
        <div class="post">
    <?php endif; ?>
    <!-- Display the Title as a link to the Post's permalink. -->
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
    <small><?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></small>
    <!-- Display the Post's content in a div box. -->
    <div class="entry">
        <?php the_content(); ?>
    </div>
    <!-- Display a comma separated list of the Post's Categories. -->
    <p class="postmetadata"><?php _e( 'Posted in' ); ?> <?php the_category( ', ' ); ?></p>
    </div> <!-- closes the first div box -->
    <!-- Stop The Loop (but note the "else:" - see next line). -->
 <?php endwhile; else : ?>
    <!-- The very first "if" tested to see if there were any Posts to -->
    <!-- display.  This "else" part tells what do if there weren't any. -->
    <p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <!-- REALLY stop The Loop. -->
 <?php endif; ?>

通过

我真的试过了,但是得到了空的描述结果,请帮忙

下面是一个在Wordpress中从post获取描述的示例



我在运行您的应用程序时没有任何问题。这个问题可能来自其他地方。作为AmarineDialog,我也测试了你的代码,它对我来说工作正常。仔细检查你的帖子是否有要显示的内容。@amarinediary我已经在live服务器上测试过了,但是本地服务器仍然不工作。帖子内容是there@cabrerahector我已经在实时服务器上进行了测试,但本地服务器仍然无法工作。帖子内容在哪里?你到底在哪里使用这个代码?请修复你的负面点击如果答案不被认为是有用的人们有权否决它,金斯莱特。不要让他们“修正”投票结果,而是要确保你的答案确实有助于提出问题的人。@KinslertVirguez。分析错误:语法错误,意外结束file@Dominic在本例中,post_title替换post_title作为post_描述
 <?php 
$categories = get_the_category( $id );
if( $categories ){
  // Assumes you just want the first category
  print 'You&#8217;re in the ' . $categories[ 0 ]->name . ' category';
}
?>
<ul>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
 
        $attachments = get_posts( array(
            'post_type'   => 'attachment',
            'numberposts' => -1,
            'post_status' => null
        ) );
         
        if ( $attachments ) {
            foreach ( $attachments as $attachment ) {
                ?>
                <li><?php echo wp_get_attachment_image( $attachment->ID, 'full' ); ?>
                    <p><?php echo apply_filters( 'the_title', $attachment->post_title ); ?></p>
                    
                </li>
                <?php
            }
        }
    endwhile; endif; ?>
</ul>
  <p><?php echo apply_filters( 'the_title', $attachment->post_title ); ?></p> <!-- do you need change post_title for description -->