WPFTS Pro Main Site WPFTS Community Forum
    • Recent
    • Tags
    • Popular
    • Register
    • Login
    Get WPFTS Pro today with 25% discount!

    How to search coupons by description in WP Coupons and Deals plugin

    Scheduled Pinned Locked Moved Recipes and Known Solutions
    wpcdcouponsdeals
    1 Posts 1 Posters 680 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • EpsilonAdminE
      EpsilonAdmin
      last edited by

      There is a good plugin for creating and displaying coupons database. It's called WP Coupons and Deals. But it has one problem - a lack of good search within coupons.

      Fortunately, with WPFTS plugin flexibility it's pretty simple to add this functionality with just some lines of code!

      Look here: actually, all we need is to put coupon description (stored in the custom post meta) to the Search Index, and additionally, we need to add coupon custom post type to the list of searchable post types.

      And here is the ready code!

      add_filter('wpfts_index_post', function($index, $post)
      {
          if ($post && $post->post_type == 'wpcd_coupons') {
              $meta = get_post_meta($post->ID, 'coupon_details_description', true);
              $index['post_content'] .= $meta;
          }
      });
      
      add_action('pre_get_posts', function(&$wpq)
      {
          if ($wpq->is_main_query() && $wpq->is_search) {
              $wpq->set('post_type', array('wpcd_coupons', 'post', 'page'));
          }
      });
      

      It was simple, do you agree?

      Oh, and one more good thing: you don't need WPFTS Pro to get this code working!

      https://e-wm.org

      1 Reply Last reply Reply Quote 0
      • First post
        Last post

      Suggested Topics

      • EpsilonAdminE

        Slow search on a site based on Divi Theme

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions
        1
        0 Votes
        1 Posts
        220 Views
        No one has replied
      • EpsilonAdminE

        How to search file by content when using PDFViewer plugin

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions embedded pdf embedpdf pdfviewer search pdf
        1
        0 Votes
        1 Posts
        695 Views
        No one has replied
      • EpsilonAdminE

        [Solved] The plugin shows wrong results for search with BeTheme template

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions betheme theme
        1
        0 Votes
        1 Posts
        793 Views
        No one has replied
      • EpsilonAdminE

        [Solved] Files not shown in TemplateToaster theme search results

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions templatetoaster theme search
        1
        0 Votes
        1 Posts
        660 Views
        No one has replied
      • EpsilonAdminE

        [Solved] WP Knowledgebase publications (kbe_knowledgebase) do not show in search results

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions knowledgebase kbe
        1
        0 Votes
        1 Posts
        681 Views
        No one has replied

      Additional Resources

      • My Account
      • Buy WPFTS Pro
      • Community Forum
      • Affiliate Program
      • Privacy Policy
      • Terms & Conditions
      • Contact Us
      • Coupon Partner

      Be the first to read the news!

      We are always improving our products, adding new functions and fixes. Subscribe now to be the first to get the updates and stay informed about our sales! We are not spammy. Seriously.

      Join Us Now!

      We are a professional IT-team. Many of us have been working in a Web IT field for more than 10 years. Our advanced experience of software development has been employed in the creation of the WordPress FullText Search plugin. All solutions implemented into the plugin have been used for 5 or more years in over 60 different web-projects.

      We are looking forward to your comments, requests and suggestions in relation to the current plugin and future updates.

      ewm-logo-450

      The forum powered by NodeBB | Contributors