php 精选图片,genesis.php

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 精选图片,genesis.php相关的知识,希望对你有一定的参考价值。

<?php
// DO NOT COPY THIS opening tag into your file. Use a code editor and ftp.

add_action( 'genesis_entry_content', 'yourprefix_display_featured_image', 5 );
/**
 * Show Featured Image Posts
 * @since  1.0.0
 */
function yourprefix_display_featured_image() {

	if ( ! has_post_thumbnail() || ! is_singular( 'post' ) ) return;
	
	$caption    = '';
	$caption    = get_post( get_post_thumbnail_id() )->post_excerpt;
		
	if ( ! empty( $caption ) ) :
		$caption = sprintf( '<figcaption>%s</figcaption>', $caption );
	endif;

	$image = genesis_get_image( array(
		'format'  => 'html',
		'size'    => 'your-featured-image-size', //change between the ticks to your featured image size
		'context' => '',
		'attr'    => '',
	) );
 	
	printf( '<figure class="featured-image aligncenter">%s%s</figure>', $image, $caption );
 		
}

以上是关于php 精选图片,genesis.php的主要内容,如果未能解决你的问题,请参考以下文章

php Wordpress获得精选图片标题

PHP Wordpress - 获取精选图片网址

PHP 将精选图片缩略图添加到WordPress管理列

php [Feat Image WP]在帖子#wordpress #php中启用精选图片

如何在没有 single.php 的情况下从 wordpress 帖子中删除特色图片

图片轮播 data-slide-to="?"使用 WordPress PHP