簡體   English   中英

wordpress新頁面的自定義主題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM