質問

I want the title and content of a specific page to show in my Homepage and footer area.

It will be something like this.

This is the Title of the page

This is the content of the page, etc....blahh blah..

                           readmore...

I know that there is no excerpt in the page post. But i want to limit the characters of the content that will show in the footer area.

Can you give me a code/link/tutorial that will show me how to do this?

Thanks,

役に立ちましたか?

解決

First there is excerpt avaIlable in the page posts. Just set it in the Screen Options.

About the code try this one which I use on my projects.

It will show excerpt of those pages, which have custom field named showOnHomePage and the value of this field determines the order in the list.

 $pages=get_posts( array( 'meta_key' => 'showOnHomePage', 'post_type' => 'page', 'orderby' => 'meta_value', 'order' => 'ASC'));

  foreach( $pages as $page ) 
  {
    echo '<h2 class="entry-title"><a href="'.get_permalink( $page->ID ).'" >'.get_the_title( $page->ID ).'</a></h2>';
    echo $page->post_excerpt;
    echo '<a class="read-more" href="'. get_permalink( $page->ID ) . '">Read More</a>';
  }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top