对于我正在处理的客户站点,客户希望能够将某些自定义帖子类型与给定页面相关联。我的主管已将我指向以前做过类似事情的客户的网站。他们使用了 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 注释掉第二行代码,那么所有帖子都会显示在侧边栏中。有没有解决这个问题的方法,或者有更好的插件吗?