Last active
February 4, 2016 10:00
-
-
Save KeSch/11228923 to your computer and use it in GitHub Desktop.
Toolbox-Modul um die WordPress-Suche zu filtern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Module Name: Seiten von Suche ausschließen | |
Description: Es werden nur Beiträge bei der WordPress-Suche berücksichtigt. [Frontend] | |
Author: Kevin Schludermann | |
Author URI: http://kevinschludermann.com | |
*/ | |
/* Sicherheitsabfrage */ | |
if ( !class_exists('Toolbox') ) { | |
die(); | |
} | |
/* Ab hier kann's los gehen */ | |
function ks_search_filter( $query ) { | |
if ( $query->is_search ) { | |
/* Nur Artikel/Beiträge berücksichtigen */ | |
$query->set('post_type', 'post'); | |
} | |
return $query; | |
} | |
/* Funktionsaufruf */ | |
add_action( 'pre_get_posts', 'ks_search_filter' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment