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

    [Solved] Exclude some PDF from results when using Download Monitor

    Scheduled Pinned Locked Moved Recipes and Known Solutions
    1 Posts 1 Posters 704 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

      When you're using the Download Monitor plugin (which is good for manage files in Wordpress), you can add some beautiful search capabilities by file content to it with the help of the WPFTS Pro plugin.

      But the question is: is it possible to exclude some files from the search results? For example, some files are private or you just don't need for them to be searched.

      The answer is YES and you can do that in at least two ways.

      Both solutions require some PHP skills to add a couple of lines of code, but it's actually very simple.

      Case 1: You want to exclude one or just some PDF files.

      To follow this method, you can just add a rule to the wp_query that excludes a set of specific posts.
      What you need to do exactly:

      • Please open each of Download Monitor's posts that you want to exclude from the search results and record it's Post ID (usually it's written in the URL of the Edit Post page).
        alt text

      • Add the small part of PHP code to your functions.php (in the root of your current theme):

      add_action('pre_get_posts', function(&$wpq)
      {
      	if ($wpq->is_search && $wpq->is_main_query()) {
                      $wpq->set('post__not_in', array( 62324 ));   // Here you need to list your IDs
      	}
      });
      

      All done! When you save modified functions.php code, the search should filter out these posts from the search results.

      P.S. This will work with ANY posts, not only Download Manager's posts or attachments. ANY posts. You even don't need to WP Fulltext Search plugin, because it's WP basic functionality.

      Case 2: You want to exclude a lot of PDF files.

      In case you want to exclude a big set of files from the search result, you need to create a special category in the Download Manager and assign all those posts to this category. And then add some PHP code to exclude all posts within this category from the search results.

      • First of all, create the Download Monitor's Category and remember it's slug.
        alt text
      • Go to the Download Monitor file's list and place some of them to this new category.
      • After it, add this code to your functions.php file.
      add_action('pre_get_posts', function(&$wpq)
      {
      	if ($wpq->is_search && $wpq->is_main_query()) {
      		$wpq->set('tax_query', array(
      				array(
      					'taxonomy' => 'dlm_download_category',
      					'field' => 'slug',
                                              // Here you need to put your category slug
      					'terms' => array( 'download-category-1' ),  
      					'operator' => 'NOT IN',
      				),
      			),
      		);
      	}
      });
      

      And that's it. After saving the functions.php all posts within this category should magically drop out of search results!

      You can download this addon and modify it for your needs to leave the functions.php file intact.

      https://fulltextsearch.org/wpfts-addon-custom-filter-dm-category-1.0.1.zip

      Hope this helps.

      https://e-wm.org

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

      Suggested Topics

      • EpsilonAdminE

        [Solved] Search PDF by content in Real3D FlipBook Plugin

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

        [Solved] No excerpts shown in search results in Storefront theme

        Watching Ignoring Scheduled Pinned Locked Moved Recipes and Known Solutions storefront theme excerpt fix
        1
        0 Votes
        1 Posts
        801 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
        789 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
        650 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
        677 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