WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
How can I add 4 featured products to my search page? (3 posts)

  1. no1se
    Member
    Posted 11 months ago #

    hi guys,

    I try to put 4 featured products above the search results so that these products can be viewed more, I tried to modify my theme's search.php and added php code <?php echo do_shortcode('[featured_products per_page="4" columns="4" orderby="date" order="desc"]');?> to the top of the search result div. But it just break the page. After a little research I found out that shortcode only can be executed in post/page content part. So now I have no idea what I can do to achieve my goal.
    Is there any template tag that I can use in my theme's php file?
    Any help will be appreciated! Thx in advance!

    http://wordpress.org/extend/plugins/woocommerce/

  2. jameskoster
    Member
    Plugin Author

    Posted 11 months ago #

    After a little research I found out that shortcode only can be executed in post/page content part.

    That's not true.

    <?php echo do_shortcode('[featured_products per_page="4" columns="4" orderby="date" order="desc"]'); ?>

    Should work just fine. When you say it 'breaks' the page, what happens?

  3. no1se
    Member
    Posted 11 months ago #

    Hi jameskoster, thx for your kind reply.
    I tried out on a vanilla wordpress site and you are right. This code works just fine.
    However Im trying to run the code on my another wordpress site which uses sphinx search plugin and encountered bad luck...
    So this should be a compatiablity problem between plugins.
    Still I suggest that you guys make a template tag which definitily works better than shortcode.
    Thx anyway!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.