【问题标题】:Use a different page template for wordpress e-commerce为 wordpress 电子商务使用不同的页面模板
【发布时间】:2012-11-12 03:26:26
【问题描述】:
我希望能够在与普通 index.php 页面不同的页面模板中显示 wordpress 插件的页面:'wp e-commerce'。
购物车的示例 URL 是:products-page/checkout/
但是,它只是将该内容放入 index.php 模板中。有没有办法创建不同的页面模板或 if/else 语句,根据用户所在的电子商务页面进行更改,例如原生 wordpress 层次结构的工作方式?
谢谢!
【问题讨论】:
标签:
php
wordpress
wordpress-theming
【解决方案1】:
我发现您可以使用条件语句定位页面标题,然后将页面标题用于结帐页面并创建:
<?php
if (is_page( 'Checkout' ) ) {
if ( have_posts() ) : while ( have_posts() ) : the_post();
the_content();
endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php }
else{ ?>
<!--Normal Page Content-->
<?php } ?>