2340条评论

  1. 我的小站每天都有不少垃圾评论,天天手工删除太费事了,有啥好方法防止他们乱发呢? 🙂

    1. 你用的是多说,建议你问问多说的客服怎么屏蔽,第三方的插件,他们得自己有这个功能才行啊。

  2. 你好,博主,我想请教一些问题:

    1.wordpress我们自定义文章类型,我已经可以实现,问下,如果增加置顶功能。

    目前我发现我新增的文章类型模块,没有置顶,和正常的文章类型有一定区别。

    2. wordpress中如果有多个自定义文章类型模块,首页显示循环文章的时候,如果将多个模块的文章全部调用出来?

    谢谢!

    1. 第一个问题可以参考这篇文章http://www.wpbeginner.com/wp-tutorials/how-to-add-sticky-posts-in-custom-post-type-archives/
      第二个问题,或者用WP_Query写自定义查询,或者直接修改主循环,在wordpress文档中有这样一段代码你可以参考,给post_type参数设置你要选择的文章类型即可。

      //Include Custom Post Types in Search Results
      function search_filter($query) {
        if ( !is_admin() && $query->is_main_query() ) {
          if ($query->is_search) {
            $query->set('post_type', array( 'post', 'movie' ) );
          }
        }
      }
      
      add_action('pre_get_posts','search_filter');
      
  3. hello,Sola

    想请教一下 关于 WooCommerce里 bill address 的问题

    因为我不需要物流地址 也不需要这个bill的地址。可是下单的时候默认会让客户去填写这个地址。如果瞎填的话淘宝那边还出现ILLEGAL_ARGUMENT

    我想直接就不要这个bill地址了。不知道应该怎么做。

    在网上早了一圈 也没找到解决办法 所以特来求助~谢谢~~

      1. 是的,这个插件可以定制checkout页面的表单字段,用代码也可以,woocommerce官方文档里就有代码示例。

        1. 用了插件后为啥不能去掉Additional information和Billing address这两行黑体大字?

        2. 插件没提供这个功能呗。这个得去改模版,checkout下的form-billing.php有billing addres,硬板吗的。additional info?是哪个页的,你找找模版呗,在插件目录搜索就行啊

  4. 你好.sola.有个关于woocommerce 的问题请教一下.
    我想在主题模版里调用woocommerce 的一个商品列表改怎么写呢?
    有类似get_wp_category.这样的固定语句吗?没有的话该怎么写呢.
    感谢您对woocommerce 用户的众多分享..

        1. WooCommerce的产品分类,即名为product_cat的custom taxonomy,用shortcode [product_categories number=”12″ parent=”0″]可以显示全部分类的前12项,若指定parent,还可以显示某个分类下的分类,这个是你需要的吗

  5. 遇到一问题,找了半天也 没发现问题出在哪了,找你帮忙!
    我使用pods这个插件创建了1个自定义分类法,并添加了A B C D几个新的分类,我想页面输出这几个分类下面相对应的 置顶文章,
    遇到的问题是:只有当terms对应的id=8的时候,能正常输出3个,其它的分类总是只输出1篇置顶文章,不知道你有没有什么好的方法,或者其它的写法,谢谢
    $args = array(
    ‘post_type’ => ‘post’, //自定义文章类型名称
    ‘showposts’ => 3, //输出的文章数量,这个可以是缺省值,不用设置
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘area_usa’,//自定义分类法名称
    ‘terms’ => array(8), //id为64的分类。也可是多个分类array(12,64)
    ),
    )
    );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post();?>

    ?php if ( is_sticky() ) : //判断内容是否置顶 ?
    ?php get_template_part( ‘home’, ‘list’ ); ?
    ?php endif; ?

    ?php endwhile; wp_reset_query(); //重置query查询
    } ?

    1. 你好,kelvin,不知道还有上线吗?想请教个问题,plugin Pods,不知道有没有办法实现,创建2个custom fields,分别是省和市,当选择了省,可以只显示该省下的市呢?
      谢谢

      1. 这个没做过不清楚,不过你可以试试这个插件http://codecanyon.net/item/wordpress-meta-data-taxonomies-filter/7002700

  6. 请教Sola一个问题
    我有两个类一个是A,一个是B,这两个类都用woocommerce实现,但是B类没有购买功能,只有展示
    这两个类的边栏会显示各自的子类菜单,我创建了不同的小工具为每个类都单独设置,现在问题是如何能让菜单只显示各自类别下面的。
    我用woo小工具那个分类调用时发现没有设置选项,它会把所有类别都显示出来。

    另外我通过创建新页面在页面里使用woo简码调用指定类别的产品,但这样会出现页面无法显示woo的那个依不同条件排序的功能。也不能使用价格过滤小工具。
    我试着将woo的archive-product.php文件改成模板页也失败了。
    困扰好久的问题,希望能帮帮我,先谢谢了

    1. 问题1,在widget中用shortcode显示某个分类下的子分类,[product_categories number=”12″ parent=”0″]
      具体介绍可以看https://www.solagirl.net/woocommerce-shortcodes.html

      问题2,请问你的目的是什么?你描述的需求正是产品分类页的功能,为什么不直接用产品分类而非要用页面去展示分类的?如果你要用page显示分类的内容,直接拷贝woo的模版不行,还得用$wp_query写自定义查询才行,filter的作用是向查询传递一些参数,更改查询结果,这些你得自己处理。

  7. 前两天给你留言你没有回, 如果想和你建立客户关系可以吗?如何联系呢?还是你现在不接任何工作?

    1. 啊, 我没回吗,难道我会错地方了,嵌套评论看着晕。我说我不擅长兼容国内的浏览器,比如IE6,搜过360等,没有做国内站点的经验。不知道你的项目具体如何,如果有问题可以发邮件给我,e.solagirl[at]gmail.com
      国内的没做过,所以我也不清楚怎么合作。国外的,我就是在elance上谈谈,项目合适就打预付款,或者全额放到elance上,项目做完后释放钱。你们怎么合作的?方便的话发邮件告诉我,谢谢!

  8. 你好,我有个主机问题想请教你,你现在的主机是用的HostGator的吗?速度这么样?我一直在用 Dreamhost的,但是最近我在做一个新的网站,发现速度很慢,所以想问你如果HG不错的话,我可能会放弃用了快10年的DH。

    能否给我一个中肯的建议,谢谢你。

    1. 我用的hostgator business plan,是打5折的时候买的。
      之前我用bluehost,及时不被屏蔽,也经常down机。hostgator稳定性和服务器性能要比bluehost好很多。

      最近我访问自己博客比较慢,用的网通,好像屏蔽了不少国外服务器,我的hostgator似乎也屏蔽了,我都开代理访问。这种事情总是一阵一阵的,只要是国外服务器,那就要看运气了。所以呢,如果你的dreamhost主机性能不错,我不建议你换hosting,先检查下是不是网站装了什么被屏蔽的服务,或者换个IP试试。

  9. 你好,看见你也用woocomerce,我找了半天,也没找到给所有产品添加同样说明的页面。请问你知道吗,非常感谢。

    1. 产品说明选项卡的内容其实就是文章的内容,用the_content filter可以实现你的要求

      add_filter( 'the_content', 'theme_wc_product_global_text' );
      function theme_wc_product_global_text( $content ){
          if( is_product() ) 
              $content .= '产品说明';
          return $content;
      }
      
        1. 你好,我没做过国内站点,换言之对兼容IE6,搜狗360浏览器等等没什么经验。如果您做的是面向国外的站点,倒是可以谈谈。有问题就给我发邮件吧,e.solagirl[at]gmail.com

      1. 你好,最近公司正在建网站,用的就是woocomerce,发现教程好少,能不能加你的联系方式呢,有些问题想问问。非常感谢。

        1. 我不怎么上qq,也没太多时间回答问题。所以可以的话就在这里留言吧,你可以把想实现的功能都告诉我,我有空时整理出代码写文章里,这样别人可以用,我可以用,你也能用^ ^

        2. 噢好的, 建站的那个人说用了the_content filter,可是不好使,让我自己复制粘贴每个页面,郁闷死。是说你不接任何项目吗?

        3. the_content不管用是不正常的,所以要找问题出在哪。可以切换到默认主题,一个个禁用插件。一个一个复制,这不太现实,等哪天要改下内容,肯定疯了。
          我是自由职业,在elance上接项目,主要做英文站。写博客就是学习知识,讨论问题,谈项目不是太有效率。如果问题有趣,我可以帮忙,但需要服务器信息的话,还是正式的客户关系比较合适。

    2. woocommerce输出产品详细信息(选项卡的那个,不是短描述)的模版是woocommerce/templates/single-product/tabs/description.php
      这个模版的代码如中

      <h2><?php echo $heading; ?></h2>
      <?php the_content(); ?>
      

      第一句是标题,第二句是内容,the_content filter就是在the_content()函数执行时加载的,如果你在the_content ()后面直接加内容都不显示,那真是要郁闷了。
      PS.这模版可以拷贝到主题里编辑,升级时从不被覆盖。

  10. 我想做2个页面:
    1、输出所有文章的评论,输出的评论格式想直接使用的是每篇文章下面输出的格式(我用的是自带的Twenty_Twelve主题,评论模版只是改了下CSS),简单说就是把所有评论直接调过来输出,格式样式都不变(包括嵌套评论),排序就按照时间,最好可以分页;
    2、我新建了个留言本页面,使用的是

    <?php comments_template( '', true ); ?>

    ,我想输出这个留言的总数量(排除作者的),也就是一个阿拉伯数字;

    希望能得到你的帮助,谢谢

    1. 第一个问题,看http://stackoverflow.com/questions/11254719/display-all-comments-for-a-wordpress-blog-on-a-single-page
      第二个问题,用get_comments,评论总数减去作者评论数即可。
      具体模版我就不给你写了,比较定制化的东西。

      1. 搞定,哈哈,再咨询个问题,

        我用advanced custom fields这个插件再后台给文章设置了个新的编辑器字段(自段名:zongjie),用来给每篇文章写总结的(默认摘要插入图片不方便),现在我想实现下面所说的效果:

        以首页为例,现在首页是输出的每篇文章的 more 截断部分,我想写个判断,如果文章zongjie字段里面有内容,就输出内容,反之输出默认截断的摘要;
        以这种输出循环下去。

        最近跟你学了不少啊,哈哈,谢谢你啊

        1. 你说的不就是流程吗,照着流程把代码写一遍就是了,用到is_home判断是否为blog index页面,用get_field( ‘zongjie’ )获取内容。
          if( is_home() ) {
          if( get_field( ‘zongjie’ ) ) the_field(‘zongjie’);
          } else {
          the_content();
          } else {
          the_content();
          }
          大概这个意思,如果你想archive页面也这样显示,在加is_archive判断。找到输出blog index内容的模版,比如twentytwelve的是content.php,把the_content那段改了就行了。

      2. XXX,
        ‘status’ => ‘approve’ //Change this to the type of comments to be displayed
        ));

        //Display the list of comments
        wp_list_comments(array(
        ‘per_page’ => 15, //Allow comment pagination
        ‘callback’ => ‘pinglun_comment’,
        ‘style’ => ‘ol’,
        ‘reply_text’ => ‘Reply’,
        ‘reverse_top_level’ => false //Show the latest comments at the top of the list
        ), $comments);
        ?>

        我使用上面这段代码来输出了所有评论(page1),但是却把我留言板页面(使用)中的留言内容也输出到(page1)了,我不想page1中出现留言板(page2)中的内容,也就是page1中输出的都是每篇文章下面的评论,这个应该怎么弄?谢谢

        1. XXX,
          'status' => 'approve' //Change this to the type of comments to be displayed
          ));

          //Display the list of comments
          wp_list_comments(array(
          'per_page' => 15, //Allow comment pagination
          'callback' => 'pinglun_comment',
          'style' => 'ol',
          'reply_text' => 'Reply',
          'reverse_top_level' => false //Show the latest comments at the top of the list
          ), $comments);
          --?>

          忘记加注释代码了,上面代码没出现完整,是这个

        2. 搞定了,不好意思美女,把我这2条留言删掉,占地方,一开始没想明白,谢谢

  11. 我很喜欢这个主题http://pan.baidu.com/share/link?shareid=2967506010&uk=3592935190里的头部文章调用及登录模块,自己试了改代码整合到我的主题当中去,可是总是以失败告终,要么幻灯片不播,要么提取不到文章的图片,高人能否提取里面的代码整合在一个文件夹中,实现调用其中一个php实现全部功能,要求整体宽950,发我邮箱,必将重谢!

  12. 又来骚扰你了美女,呵呵,问个问题,如下:

    归档如何这样显示调用
    2013
    --12月
    --11月
    2012
    --10月

    就想自定义调用某年下面的所有月份

  13. Sola 你好,做WooCommerce 站点遇到一个问题:
    我的主题在产品详情页里,只想留一个单张的Featured Image,不想要包含那一组 Product Gallery。
    不知道合理的做法是怎样的?
    谢谢!

  14. Thanks Sola. Previously I have built woocommerce file under child theme so i can get access to archive-product.php through dash board. It has code as you said:

    There is also sidebar.php in child theme. But there is no sidebar-shop.php (Found sidebar.php in child theme/woocommerce/shop/sidebar.php)
    Any clue?

    1. The sidebar.php is supposed in the root folder of your current theme, and it must be calling a sidebar that’s already registered in WordPress.

      1. Sola,
        To achieve sidebar functions in woocommerce page, we can use plugin – woosidebars.
        It can create different sidebars for different pages. Hope it helps people who need it.

  15. Thanks Sola, I have tried that. Catalog image size is bigger now. But I need custom sidebar for catalog page.
    Do you have idea how to add custom sidebars to category page? I don’t see where I can add it yet.

    1. Woocommerce has a sidebar by default, I guess your theme might have removed that.
      Please check if there is a woocommerce folder in your theme folder, the template for product archive page is archive-product.php, find it and check the code that calls for a sidebar
      do_action(‘woocommerce_sidebar’);
      If there is no such code in archive-product.php, just add it.

      WooCommerce will try sidebar-shop.php first, and then sidebar.php, please make sure there is a sidebar.php in your theme.

      1. I just changed height settings in WC from 9999 to 198, which is same as width. And some images become smaller now.
        Please have a look. But the images are not centered. I add following code, but it didn’t work. what could be wrong?

        .prod-image-wrap {
        vertical-align: middle;
        }

        1. Use code below to make images on archive page horizontally centered.
          ul.products li.product a img{
          margin-left:auto;
          margin-right:auto;
          }

          I’m not sure about the vertical-align, I don’t see why image must be vertically centered. Besides the vertical-align rule doesn’t apply to block elements.

  16. Hi Sola, It’s clear in IE 9.0 as well after I added one more line into CSS. Found this on line. Can you explain how it solved the problem? Thanks.

    div.product div.images img, #content div.product div.images img {width:auto;}
    ul.products li.product a img { width:auto; height: auto;
    .related ul.products li.product img, .related ul li.product img, .upsells.products ul.products li.product img, .upsells.products ul li.product img { width: auto; height: auto; }

    I hope it can help someone who has similar problem.

    1. The solution is not to zoom the image, make the image sizes defined in css exactly the same as what’s defined in your stylesheet. When images are zoomed, they become blurry.
      For example, http://www.oil-painting.com.au/product/adam-and-eva/
      You have this rule in your stylesheet
      .woocommerce .images img {
      max-width: 370px !important;
      }
      Which makes the max image with 370px, while in fact the container of single product image has a max width of 431px.
      So if you remove the max-width:370px thing from your stylesheet, and make the single image width 431px, it will look better.

      Here is the image width I suggest.
      Catalog Images: 431px
      Single Product Image: 198px

      After you change the image settings, you should use Regenerate Thumbnails plugin to recreate your image thumbs.

      Here is an article that explains the blurry image issue in woocommerce in detail.
      http://nhab.it/blog/2012/10/08/how-to-fix-the-woo-commerce-blurry-product-images-problem/

      Thank you for sharing your experience, I appreciate that very much!

  17. Hi Sola, I just added following css to my custom css and the images become clear in Firefox.

    div.product div.images img, #content div.product div.images img {width:auto;}
    ul.products li.product a img { width:auto; height: auto;

    But it is still blurry in IE 9.0.

    What could have been wrong?

  18. solagirl好

    在woocommerce 中,catalog 的图片有些比较模糊,并且大大小小, 有没有办法改善?URL: oil-painting.com.au/product-category/Gustav-Klimt
    Woocommerce 里设定是宽度150, 高度9999, 我想做成类似 allposter.com里目录显示的大小和清晰度。谢谢!

    1. 你好,woocommerce图片模糊一般是因为后台设定的图片尺寸比主题css定义的尺寸小,这两个尺寸一致,图片一般都没事。
      你站点这两个尺寸是一致的,但原始图片好像有些模糊。

    1. 很抱歉,你的评论被截掉一部分,最好不要发大段的代码,如果要发代码,请看评论框上的提示。

  19. 请问下为什么收不到订单邮件?

    测试woo-commerce是,用支付宝付款成功,也返回到了订单完成页面。但是,woocommerce的订单状态,还是显示pending,而不是处理中。

    这样系统就不会发出订单邮件。请问这如何解决?

    1. 我用支付宝测试时订单状态都会变成processing,这个是靠异步返回完成的,类似paypal IPN这种,所以如果返回时服务器超时,就会丢单。你可以开启debug看看,有没有支付宝向你服务器post信息的记录。我无法重现这个错误,所以也没法在这里帮你解决。

  20. 有没有什么方法可以修改wordpress前台页面代码中plugin目录名字,很容易暴露自己用的插件,看到你用的是wp-minify,呵呵;
    我有试用一些安全插件去改变wp-content这些目录的名字,还是有问题,有时候安装插件不能正确读取语言包,修改插件中语言包路径也有问题,不知道你有没有什么好的方法。

    1. 这你得去问安全专家,我见很对明博还列出自己用的插件呢。只要你用的插件没什么安全漏洞就行吧。要隐藏的话,连自己网站是用wordpress搭建这件事也得算上。

  21. 你好,我有个问题想请教一下,我用这个插件,产品在首页展示的时候没有很大的缩略图,只有文字喝一个小图案,请问这是什么原因???谢谢您

  22. sola 能不能出一套 WPML给我?

    WPML Multilingual CMS – Version 2.9.3, Released on Oct 8th, 2013
    WPML String Translation – Version 1.9, Released on Oct 8th, 2013
    WPML Translation Management – Version 1.8, Released on Oct 8th, 2013
    WPML Sticky Links – Version 1.3, Released on April 18th, 2013
    WPML CMS Nav – Version 1.4, Released Oct 8th, 2013
    WPML Media – Version 2.0.2, Released Oct 8th, 2013

    如果可以,怎么赞助?

    1. 你是指submit按钮吗?这种就是普通的post,跟php的post事件没什么区别啊。一般会配合save_post这个action使用。当然, 这篇文章介绍的脚本跟Advanced Custom Fields比,还是后者更实用。

  23. Please provide us some live websites profile of your work. We’re looking for developer for wordpress. joomla and good in PHP. We saw your profile on elance and hope you can send me an email to further discuss our projects. Cheers!

    Regards
    JEFF LIM

  24. Sola,您好,我想请教一下,WooCommerce如何在运费那里添加一个自定义的运费项目,弄了好久搞不定….