• Resolved pierreb

    (@pierreb)


    Hi all!
    If you’re using the Promotion slider just as a slideshow with a link to a different post you probably don’t want that slider to show up in the search result list.

    For example. Let’s say I create a Promotion called “Welcome” and just add a nice banner/image to it. If someone search for “Welcome” they will find this empty post in the search result list!

    To exclude all promotions from the search results list you can modify the plugin a little.
    This is how you do it!
    Open/Edit: …plugins/promotion-slider/includes/post_type.php
    Around line 31 you’ll find this piece of code:

    function register_post_type(){
    		  // Create array of arguments for post type
    		  $args = array('labels' => array('name' => $this->plural,
    				'singular_name' => $this->singular,
    				'add_new' => 'Add New '.$this->singular,
    				'add_new_item' => 'Add New '.$this->singular,
    				'edit_item' => 'Edit '.$this->singular,
    				'new_item' => 'New '.$this->singular,
    				'view_item' => 'View '.$this->singular,
    				'search_items' => 'Search '.$this->plural,
    				'not_found' => 'No '.$this->plural.' found',
    				'not_found_in_trash' => 'No '.$this->plural.' found in Trash'),
    				'public' => true,
    				'rewrite' => array('slug' => $this->slug));

    Add an argument…
    We need to add an argument in this array, telling WP not to show this kind of post type on search. Fortunately we can use an argument called exclude_from_search Read more about these arguments here

    Now that we know what argument to use, we simply just have to add it to the array above. This is what it looks like when we’re done:

    function register_post_type(){
    		  // Create array of arguments for post type
    		  $args = array('labels' => array('name' => $this->plural,
    				'singular_name' => $this->singular,
    				'add_new' => 'Add New '.$this->singular,
    				'add_new_item' => 'Add New '.$this->singular,
    				'edit_item' => 'Edit '.$this->singular,
    				'new_item' => 'New '.$this->singular,
    				'view_item' => 'View '.$this->singular,
    				'search_items' => 'Search '.$this->plural,
    				'not_found' => 'No '.$this->plural.' found',
    				'not_found_in_trash' => 'No '.$this->plural.' found in Trash'),
    				'public' => true,
                                    'exclude_from_search' => true,
    				'rewrite' => array('slug' => $this->slug));

    Hopefully this was helpful for some of you out there. Please remember that if you update the plugin with a new version, all your modifications will be gone and your promotions will be visible in the search result again!

    Thanks,
    Pierre

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thanks Pierre. This is exactly what I needed

    I wish to exclude the slider from showing up in the search results … but I am not finding the file (below and referenced above)in my version ot the promotion slider 3.3.1

    plugins/promotion-slider/includes/post_type.php

    Can anybody please help?

    Thanks

    Ash

    Thread Starter pierreb

    (@pierreb)

    Hi Ashley2011,

    I had a look at the new version of the plugin.
    The author of it has moved the post_type.php file into a folder named “classes“.
    New URL: plugins/promotion-slider/classes/post_type.php

    Around line 47 in post_type.php, you’ll find the same array you need to modify/add some code to.

    Hope this helps!
    Cheers,
    //Pierre

    Hey Pierreb,
    Thanks very much for your help … your last post helped me to solve my issue.

    Ashley

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: Promotion Slider] How to disable the promotions from being visible in the search result lis’ is closed to new replies.