【问题标题】:Wordpress - Post Page Associator IssuesWordpress - 帖子页面关联问题
【发布时间】:2012-06-06 23:35:56
【问题描述】:

对于我正在处理的客户网站,客户希望能够将某些自定义帖子类型与给定页面相关联。我的主管已将我指向以前做过类似事情的客户的网站。他们使用了 Post Page Associator 插件(似乎已从插件列表中删除)。

这是我正在使用的插件的链接:http://www.mediafire.com/?2dpbxac73rsn8l6

我已尽力修改插件内的代码以处理我想使用的自定义帖子类型(这些更改包含在下载中)。主要冲突来自这段代码(来自之前客户端的page.php文件)

<?php 
    $sidebar = new WP_Query( $args ); //queries for posts
    $sidebar = wp_plugin_post_page_associator::get_associated_posts ($post->ID); //looks for associated posts via the plugin, the main offending line of code
    if ($sidebar!="") : while ( $sidebar->have_posts() ) : $sidebar->the_post();
    ?>
    <div id="sidebar-content"> <!-- sidebar area -->
        <h1 class="blue-text"><?php the_title(); ?></h1> <!-- the title of the associated post -->
        <div class="divider"></div>
        <?php the_content(); ?> <!-- the content of the associated post-->
        <br/><br/>
    </div>
    <?php endwhile;  else:?>

        <br/><br/>
    <?php endif; ?>

我想知道是否有办法确定相关内容的帖子类型,以便我可以相应地更改 WP_Query 设置。如果我用 $sidebar 注释掉第二行代码,那么所有帖子都会显示在侧边栏中。有解决这个问题的方法吗,或者有更好的插件吗?

【问题讨论】:

  • 对不起,也许是我,但你能更好地解释一下你的主要最终目标是什么吗?
  • 我希望能够将自定义帖子类型与页面关联(在编辑页面屏幕上,我可以选择自定义帖子类型的条目与之关联)。关联的自定义帖子类型显示在侧边栏区域的页面上。

标签: wordpress plugins associations


【解决方案1】:

我找到了一个替换插件,它完全可以满足我的需要,并向我展示了如何做到这一点:http://www.cssigniter.com/ignite/custom-post-types-relationships/

【讨论】:

  • 感谢您解决自己的问题,但 SO 不赞成仅链接的答案,因为它们会受到链接腐烂的影响。仅供参考。
猜你喜欢
  • 1970-01-01
  • 2013-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-04
  • 2023-03-17
相关资源
最近更新 更多