首页 文章

Wordpress内容无法显示

提问于
浏览
2

您好我是wordpress的新手,我正在尝试为网站创建自己的自定义主题,我理解我所做的一些但我必须承认,有些东西对我来说仍然很奇怪 . 我现在的问题是,当我添加一个新页面并且我向该页面添加内容时,当我访问该网站时内容不会显示但页眉和页脚显示正常,我已检查了源代码和注意到内容没有生成 .

这些是我的custom themefile的代码文件:

[header.php文件]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
        <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/menu.css" type="text/css" />
        <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &raquo; Blog Archive <?php } ?> <?php wp_title(); ?></title>
    </head>
    <body>
        <div id="header">
            <div class="content">
                <div id="logo-with-contact">
                    <img src="<?php bloginfo('template_url') ?>/images/Amissah, Amissah - Logo.png" alt="Amissah, Amissah & Co" id="header-image" />
                    <div class="clear"></div>
                </div>
            </div>
            <nav id="top-menu-nav">
                <ul>
                    <li><a href="<?php echo get_option('home') ?>">Home</a></li>
                    <?php echo wp_list_pages('sort_column=menu_order&depth=1&title_li='); ?>
                </ul>
            </nav>
        </div>
        <div class="clear"></div>

[Footer.php]

<div id="footer">
    <div class="content">
      <div class="block" style="margin-left: 0px">
        <h3>Quick Links</h3>
        
<ul> <li><a href="our-firm.html">Our Firm</a></li> <li><a href="our-practices.html">Our Practices</a></li> <li><a href="resources.html">Resources</a></li> </ul> </div> <div class="block"> <h3>About Us</h3>
<ul> <!--<li><a href="corporate-info.html">Corporate Info</a></li>--> <li><a href="staff.html">Staff</a></li> <li><a href="testimonials.html">Testimonials</a></li> </ul> </div> <div class="block"> <h3>Stay Connected</h3>
<ul> <li><a href="#" title="facebook"><img src="<?php bloginfo('template_url') ?>/images/facebook-icon.png" alt="facebook" />&nbsp;Join us on facebook</a></li> <li><a href="#" title="twitter"><img src="<?php bloginfo('template_url') ?>/images/twitter-icon.png" alt="twitter" />&nbsp;Follow us on twitter</a></li> <li><a href="https://login.secureserver.net/index.php?app=wbe" title="mail"><img src="<?php bloginfo('template_url') ?>/images/E-Mail.png" alt="staff mail" />&nbsp;Staff Email</a></li> </ul> </div> <div class="block" style="width:220px; line-height: 18px;"> <h3>Contact Us</h3>
Email: info@example.com
Location: xxxxx-xxxxx Memorial Court,
F xxx/5, xth xxxxx Street,
xxxx xxxx Avenue, xxxx,
Adjacent the xxxx xxxxxx Embassy,
Accra
Telephone: xxxx xxx xxx </div> <div class="clear">

</div> <div class="horizontal-divider"></div> </div> </div> </body> </html

[的index.php]

<?php get_header(); ?>

<div id="main" class="site-main">
    <div class="content">

    </div>
</div>

<?php get_footer(); ?>

3 回答

  • 0

    按照WordPress,

    The Loop 是WordPress用于显示帖子的PHP代码 . 使用The Loop,WordPress处理每个帖子以显示在当前页面上,并根据它与The Loop标签中指定条件的匹配方式对其进行格式化 . 循环中的任何HTML或PHP代码都将在每个帖子上处理 .

    可以在这里找到,http://codex.wordpress.org/The_Loop

    <?php 
    if ( have_posts() ) {
        while ( have_posts() ) {
            the_post(); 
            //
            // Post Content here the_content();
            //
        } // end while
    } // end if
    ?>
    

    基本上,“循环”是WordPress的动态部分,它会吐出页面,帖子和其他内容 .

  • 0

    看起来你错过了循环,这是wordpress用来遍历传递给模板并呈现内容的任何帖子/页面 .

    尝试将此添加到内容div中的index.php

    <?php if(have_posts()) : ?>
        <?php while ( have_posts() ) : the_post() ?>
    
        <h1><?php the_title(); ?></h1>
        <?php the_content(); ?>
    
        <?php endwhile; ?>
    <?php endif; ?>
    

    你可以在这里阅读所有相关信息 - http://codex.wordpress.org/The_Loop

  • 2

    将以下COde放在index.php之后

    <div id="primary" class="site-content">
        <div id="content" role="main">
        <?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 twentytwelve_content_nav( 'nav-below' ); ?>
    
        <?php else : ?>
    
            <article id="post-0" class="post no-results not-found">
    
            <?php if ( current_user_can( 'edit_posts' ) ) :
                // Show a different message to a logged-in user who can add posts.
            ?>
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'No posts to display', 'twentytwelve' ); ?></h1>
                </header>
    
                <div class="entry-content">
                    <p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.', 'twentytwelve' ), admin_url( 'post-new.php' ) ); ?></p>
                </div><!-- .entry-content -->
    
            <?php else :
                // Show the default message to everyone else.
            ?>
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
                </header>
    
                <div class="entry-content">
                    <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
                    <?php get_search_form(); ?>
                </div><!-- .entry-content -->
            <?php endif; // end current_user_can() check ?>
    
            </article><!-- #post-0 -->
    
        <?php endif; // end have_posts() check ?>
    
        </div><!-- #content -->
    </div><!-- #primary -->
    

相关问题