[英]custom theme for wordpress new page
我为word-press创建了一个自定义主题。 当我说'添加新'页面并且我将内容放入此页面时,它只显示页脚和页眉,但dosnt挂钩我在该页面上的CMS中的内容。
这就是我所拥有的:page.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-12">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div> <!-- /.col -->
</div> <!-- /.row -->
<?php get_footer(); ?>
这是漫长的一天,我在这里做错了什么。 有什么提示吗?
还希望像这个新页面中的父页面一样,但它唯一的页面属性选项是“默认模板”。
如果你没有模板部分,请使用the_content()而不是get_template_part('content',get_post_format());
我的实际问题,解决了。 所以我为我的WordPress使用了'高级自定义字段'插件。 使用它的问题是它仍然需要你做一些编码。
我添加了一个新页面。
对于该页面,我有一个标题图像和内容。 因此,对于ACF(高级自定义字段),它等于两个字段类型“图像 - >字段类型和文本区域 - >字段类型”
字段名称是我用来调用我的.php页面模板的字段。
字段名称:Image = header-image
字段名称:(2)文本区域= header-image-text-top(和)header-image-text-author
(我需要在图像上显示我的文本,这就是为什么我的div只是基于标题图像。)
所以我挂钩了我的页面模板,然后为我要在此页面模板上显示的字段添加了钩子。
page-stay.php:
<?php
/*Template Name: Stay - Parent Page */
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post=<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- <header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header>(you can use this if you need your page header to display)-->
<div class="enry-content">
<?php
$image = get_field('header-image');
if( !empty($image) ): ?>
<div class="head-image">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="head-text-box">
<div class="head-text-box-holder">
<p class="headtext-quote"><?php the_field('header-image-text-top'); ?></p>
<p class="headtext-author"><?php the_field('header-image-text-bottom'); ?></p>
</div>
</div>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.