【问题标题】:Wordpress: Load page content into custom template/themeWordpress:将页面内容加载到自定义模板/主题中
【发布时间】:2012-10-04 16:32:40
【问题描述】:

我使用 Starkster 从头开始​​创建了一个自定义主题,以获得一个静态的 wordpress 版本没有帖子/cmets。另外,我在 Wordpress 中添加了六个页面,其中包含一些内容。

所以,设计工作到现在为止,但我无法将这些页面的内容加载到网站/浏览器中。一个 DIV 在 header.php 中打开并在 footer.php 中关闭,我想,内容会在两者之间加载。

这是迄今为止使用的:

index.php:

<?php get_header(); ?>
<?php get_footer(); ?>

page.php:

<?php get_header(); ?>
<?php the_content(); ?>
<?php get_footer(); ?>

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>
<title><?php bloginfo( 'name' ); ?><?php wp_title( '|' ); ?></title>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"><!-- REmove if you're not building a responsive site. (But then why would you do such a thing?) -->
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/img/favicon.ico"/>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="oben"></div>
<div id="naviwrap">
<div id="titel"><h1 class="titelbutton"><a href="http://www.studio-scs.de">Coach</a></h1></div>
<div id="navigation">
<a class="navibutton" href="/" title="START">START</a>
<a class="navibutton" href="/coaching/" title="COACHING">COACHING</a>
<a class="navibutton" href="/termine/" title="TERMINE">TERMINE</a>
<a class="navibutton" href="/person/" title="PERSON">PERSON</a>
<a class="navibutton" href="/kontakt/" title="KONTAKT">KONTAKT</a> 
<a class="navibutton" href="/impressum/" title="IMPRESSUM">IMPRESSUM</a>
</div>
</div>
<div class="clearer"></div>
<div id="wrap" class="inhaltverlauf">
<div id="blocker"></div>
<div id="inhalt">

页脚.php:

</div>
<div class="clearer"></div>
</div>
<div id="farbhintergrund" class="farbverlauf"></div>
<?php wp_footer(); ?>
</body>
</html>

您可以在这里查看:studio-scs.de


Elias 对我帮助很大,但还有另一个问题。与

page.php

<?php get_header(); ?>

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

<?php get_footer(); ?>

我已按我的意愿删除了所有帖子,但如果我现在只想在其中一个页面(例如 Termine)上恢复发布功能,以便有可能添加新日期等,如何我这样做?

【问题讨论】:

    标签: wordpress themes loaded


    【解决方案1】:

    你不能在没有查询的情况下使用the_content

    将您的行 the_content() 替换为以下内容:

    <div id="content" class="widecolumn">
     <?php if (have_posts()) : while (have_posts()) : the_post();?>
    
     <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
    
      <?php the_content(); ?>
    
    
     <?php endwhile; endif; ?>
     <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    </div>
    

    【讨论】:

    • 非常感谢。不幸的是,我还有一个问题(见上文)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 2011-12-02
    • 2023-03-03
    相关资源
    最近更新 更多