【问题标题】:Problem with blog posts in integrating wordpress with existing site.将 wordpress 与现有网站集成时的博客文章存在问题。
【发布时间】:2013-11-19 19:33:27
【问题描述】:

我正在尝试将 wordpress 集成到我现有的站点中,因此我将 wordpress 文件放在 Localhost/site/blog 目录中,因为我不想在包含所有包含/样式表/图像文件夹的情况下弄乱我的根目录。

我还希望博客模仿我网站的设计。这就是为什么我刚刚创建了 blog.php 并将其放在根目录中,然后将它放在我的 blog.php 之上,这样 wordpress 就可以与 blog.php 一起使用。即使它不在 wordpress 目录中。

<?php 
define('WP_USE_THEMES', false);
require('./blog/wp-blog-header.php'); 
?> 

然后我把循环放在body标签里面,一切看起来都很好。博客文章出现。它们完美对齐。

<!-- Start the Loop. -->        
 <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

 <?php if ( in_category('3') ) { ?>
           <div class="post-cat-three">
 <?php } else { ?>
           <div class="blogpostcontainer">
                <div class="blogpost">
                     <div><img src="images/blogpost_picture.jpg" width="125" height="125" alt="blogpost" /></div>
                        <div class="info">
 <?php } ?>
 <!-- Display the Title as a link to the Post's permalink. -->
 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

   <?php the_excerpt(); ?>
 <p><span class="date"><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></span></p>
                        </div><!--END OF info div-->
                  </div><!--END OF blogpost div-->
              </div><!--END OF blogpostcontainer div-->
 <?php endwhile; else: ?>

现在的问题! 好吧,问题是,每当我尝试单击帖子的永久链接(查看整篇帖子)时,我都会得到一团糟:那里的一切都没有任何 CSS 或任何东西。

我只是想知道,我怎样才能让帖子看起来不错,我知道我必须创建 single.php 或 page.php?(或者我是吗?),但我不知道放在哪里。它是在 wp 目录中,还是在我的根目录中? 如果您还有问题或问题含糊不清。请告诉我。谢谢

【问题讨论】:

    标签: php wordpress post blogs


    【解决方案1】:

    single.php(用于帖子)/page.php(用于通用页面)应该在您的/wp-content/themes/&lt;active theme&gt;/ 目录中。

    【讨论】:

      【解决方案2】:

      最有可能的是singe.php和page.php已经存在了。

      您应该将设置中的 URL 更改为 localhost/site/blog

      您可以在这里找到更多信息:http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2014-04-23
        • 2014-10-07
        • 2010-12-06
        • 1970-01-01
        • 2012-01-24
        • 2021-04-16
        • 2015-12-11
        • 1970-01-01
        相关资源
        最近更新 更多