【问题标题】:Wordpress woocommerce empty my account + car pageWordpress woocommerce清空我的帐户+汽车页面
【发布时间】:2015-11-16 11:06:30
【问题描述】:

我在尝试安装 woocommerce 时卡住了。我添加设法做到了,但是突然间,我不知道为什么,“我的帐户”页面和“购物车”页面都是空的,如果我查看源代码,内容就在这里,但介于两者之间,因此是不可见的。我不知道,一直在互联网和 stackoverflow 上搜索几个小时,但没有运气! 有人知道为什么会这样吗?

我已经重装了3次插件,删除了所有东西,重新安装了,还是一样的错误....

我没有触及代码中的任何内容,页面是在后端选择的

编辑: 我的 woocommercePage 是

<?php get_header(); ?> 
<?php woocommerce_content(); ?> 
<?php get_footer(); ?> 

我的页面是:

   <?php get_header(); ?> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 
<?php endwhile; ?> 
<?php else : ?>
 <?php endif; ?> 
<?php get_footer(); ?>

【问题讨论】:

  • 您的主题页面模板似乎已注释掉 the_content()...我会看看 page.php 或任何模板部分(取决于主题)
  • 似乎没有任何东西可以导致该评论(见编辑后的帖子):/但我同意你的理论,因为如果我将 {woocommerce_cart} 短代码复制到随机页面,突然购物车在该页面上显示得很好...
  • Eeek,不要在 cmets 中发布那么多代码。编辑您的问题并正确格式化代码,以便人们实际阅读。
  • 并始终尝试切换到默认主题(如二十五)以查看问题是否仍然存在。如果不是,您已将问题隔离到您的主题。
  • @helgatheviking 好的,我确实切换到了 TwentyFiften,一切正常。这是个好主意,谢谢。在我的主题中,问题可能出在哪里?它基于“骨头”。

标签: php html wordpress woocommerce


【解决方案1】:

WooCommerce“我的帐户”和“购物车”页面应该只是常规的 WordPress 页面。 WooCommerce 功能是通过在页面内容中使用短代码添加的。如果您愿意,您还可以包含其他内容和简码,但以下简码是必需的。

对于 Cart 使用:

[woocommerce_cart]

对于 My Account 使用:

[woocommerce_my_account]

您的页面模板需要调用the_content(),以便$post-&gt;post_content 值通过the_content 过滤器,该过滤器将调用do_shortcode() 来处理短代码。

<?php get_header(); ?> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<!-- output the page content here to process shortcodes -->
<?php the_content(); ?>

<?php endwhile; ?> 
<?php else : ?>
 <?php endif; ?> 
<?php get_footer(); ?>

【讨论】:

  • 您的页面没有输出任何内容。在while循环中添加&lt;?php the_content(); ?&gt;,看看是否有效。
  • 我相信这是问题所在!我不明白购物车/我的帐户是基于“page.php”模板而不是“woocommerce.php”
猜你喜欢
  • 1970-01-01
  • 2016-08-23
  • 1970-01-01
  • 2019-04-04
  • 2017-12-16
  • 1970-01-01
  • 2017-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多