【问题标题】:Cannot determine wordpress sidebar content is coming from无法确定 wordpress 侧边栏内容来自
【发布时间】:2013-10-07 12:32:44
【问题描述】:

我继承了这个项目,原来的设计师早已不在。而且我对 Wordpress 不是很熟悉。

this page 我不知道这个侧边栏是如何生成的。我grep'ed 整个目录寻找诸如“Bill Johnson”或“Rocky Mountain News”之类的内容,但它不在 Wordpress 文件中。所以,它必须是数据库的一部分。

但该网站没有小部件或帖子。在 Pages 下,我没有看到包含侧边栏的选项。

这是 wp-content/themes 目录中的代码。

侧边栏.php: <?php print get_post_meta($post->ID, "sidebar_var", true); ?>

page.php:

<div id="content">
    <div id="left">

    <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>
            <?php the_content('Read the rest of this entry &raquo;'); ?>
        <?php endwhile; ?>
    <?php else : ?>
        <p>Sorry, no posts matched your criteria.</p>
    <?php endif; ?>

    <!-- End #left --><br class="cl" /></div>

<?php get_sidebar();?>

  <!-- End #content --><br class="cl" /></div>

<?php get_footer();?>

非常感谢任何指导。

【问题讨论】:

  • 查看您的页面源代码,它看起来可能是硬编码的。您是否查看过 get_sidebar();看看它是否在那里?
  • 正如您从 Codex (codex.wordpress.org/Function_Reference/get_post_meta) 中看到的那样,get_post_meta 从自定义字段中获取内容。尝试转到 wordpress 后台的那个页面,那里可能有一些包含该信息的自定义字段。
  • 发布sidebar.php的内容。这很可能是生成右侧 HTML 的位置。

标签: php wordpress


【解决方案1】:

感谢克苏鲁的建议,检查数据库,wp_postmeta 表中有一条记录,meta_key 字段设置为值sidebar_var。同一记录的meta_value 字段具有侧边栏html。不知道为什么最初的设计师会这样做,但我会重构以使用小部件。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-04
    • 2012-07-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多