所以这里的代码使得英雄出现在我的wordpress网站的博客部分(当我填充一个名为" intro"的自定义帖子类型时):
<?php
$args = array( 'post_type' => 'intro', 'posts_per_page' => 1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
---more code here---
<?php endwhile; ?>
我想知道在后两行中我可以改变什么,以便在我选择作为主页的任何页面上发生效果。
由于
编辑1:
<?php /* Template Name: eFrontpage */ ?>
<?php
$args = array( 'post_type' => 'intro', 'posts_per_page' => 1 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="point-1"></div>
<div class="home-intro" style="background-image: url(<?php
the_field('background-image'); ?>)">
<div class="home-intro-inside">
<h1 class="<?php the_field('intro_text_color'); ?>">
<?php the_field('intro-text'); ?>
</h1>
<a class="scroll-down <?php the_field('button_text_color'); ?>"
style="background-color: <?php the_field('button-background-color');
?>">
<?php the_field('button-text'); ?>
</a>
</div>
</div>
<div class="space"></div>
<script>
jQuery("body").addClass("intro-is");
</script>
<?php get_header(); ?>
<div id="primary" class="content-area container">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
?>
<?php endwhile; // end of the loop. ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
答案 0 :(得分:0)
你不需要在那里改变任何东西。您需要将创建英雄部分的循环复制到首页模板代码中。根据为英雄部分设计样式的CSS,它可能无法开箱即用。
您还应确保使用子主题,而不是覆盖原始主题。