[Plugin: Promotion Slider] How to disable the promotions from being visible in the search result lis
-
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 hereNow 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
- The topic ‘[Plugin: Promotion Slider] How to disable the promotions from being visible in the search result lis’ is closed to new replies.