我使用的是Gazette主题,当首页设置为显示最新帖子时,它有一个支持jet pack的特色帖子网格。
我想使用静态页面而不是最近的帖子,但要保留特色帖子网格。
<小时>
UPDATE
在社区的一点道义支持下,我终于明白了这一点
链接到答案-Display Featured Posts Grid on Static Page (Gazette)
演示:https://gazettedemo.wordpress.com/
资料来源:https://public-api.wordpress.com/rest/v1/themes/download/gazette.zip
Code parts associated with the featured posts
@ 指数php
<?php
if ( is_home() ) {
// Include the featured content template.
get_template_part( \'featured-content\' );
}
?>
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
get_template_part( \'content\', get_post_format() );
?>
<?php endwhile; ?>
<?php the_posts_navigation(); ?>
<?php else : ?>
<?php get_template_part( \'content\', \'none\' ); ?>
<?php endif; ?>
@功能。php第197行
wp_enqueue_script( \'gazette-featured-content\',
get_template_directory_uri() . \'/js/featured-content.js\',
array( \'jquery\' ), \'20150507\', true );
@特色内容。php
$featured_posts = gazette_get_featured_posts();
if ( empty( $featured_posts ) ) {
return;
}
?>
<?php
foreach ( $featured_posts as $post ) {
setup_postdata( $post );
// Include the featured content template.
get_template_part( \'content\', \'featured-post\' );
}
wp_reset_postdata();
?>
@内容特色帖子。php
/**
* The template for displaying featured posts on the front page
*/
<?php
// Output the featured image.
if ( has_post_thumbnail() ) {
the_post_thumbnail( \'gazette-featured-content-thumbnail\' );
}
?>
@公司/jetpack。php第22行
add_theme_support( \'featured-content\', array(
\'filter\' => \'gazette_get_featured_posts\',
\'description\' => __( \'Omitted\', \'gazette\' ),
\'max_posts\' => 6,
) );
@js/特色内容。js 24号线
var featuredContent, header, primary;
featuredContent = $( \'#featured-content\' );
header = $( \'#masthead\' );
primary = $( \'#primary\' );
if ( ! featuredContent.length ) {
return;
}
@js/标题。js 24号线
function headerStyle() {
var featuredContent, featuredContentHeight;
featuredContent = $( \'#featured-content\' );
featuredContentHeight = 0;
if ( featuredContent.length ) {
featuredContentHeight = featuredContent.outerHeight();
}
if ( $( \'.site-branding\' ).outerWidth() === 0 ) {
$( \'body\' ).addClass( \'no-branding\' );
} else {
$( \'body\' ).removeClass( \'no-branding\' );
}
这些都是我找到的关于特色帖子网格布局的参考资料。
如何修改以在主页设置中将网格显示为静态页面?
Notes
我将此添加到页面。php,它确实显示在静态源代码中,但只是不显示。
if ( is_page(35) ) {
// Include the featured content template.
get_template_part( \'featured-content\' );
}