Design · PHP · Server

Design · PHP · Server

WordPress · Drupal · PrestaShop

  • Startseite
  • WordPress
  • PHP
  • Ubuntu
  • Prestashop
  • Indesign
  • Grafik
You are here: Home / WordPress / Genesis: Blogpage auf eine bestimmte Kategorie beschränken

Genesis: Blogpage auf eine bestimmte Kategorie beschränken

7. Juni 2017 Leave a Comment

Mit diesem Code in der functions.php kann man beim Genesis Framework die auf der Blogpage angezeigten Beiträge auf eine bestimmte Kategorie beschränken

add_action( 'pre_get_posts', 'sk_show_posts_from_a_category_posts_page' );
/**
 * Show Posts from a specific category on Posts page
 *
 * @author Bill Erickson
 * @author Sridhar Katakam
 * @link http://www.billerickson.net/customize-the-wordpress-query/
 * @param object $query data
 *
 */
function sk_show_posts_from_a_category_posts_page( $query ) {

	if( $query->is_main_query() && !is_admin() && is_home() ) {
		$query->set( 'category_name', 'category-1' ); // Replace "category-1" with your category slug
	}

}

Quelle: Bill Erickson | Sridharkatakam.com

Filed Under: WordPress Tagged With: Code Snippets, genesis

Schreibe einen Kommentar Antworten abbrechen

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Themen

Adminbar Apache Attachment Count Automatische Updates Backend Boolean values Boolesche Werte BuddyPress Code Snippets Concatenation Operator Conditional Statement Datenbank Email Enfold Escape Zeichen Galerien genesis Grid View htaccess Layout Builder List View Logische Operatoren Loops Maskieren Media Manager Mitgliederbereich PHP PHP Anfänger PHP Variablen Plugins Prestashop Prestashop 1.5 Prestashop 1.6 Prestashop Module Registrierung RSS Feed s2member Server ssl Strings Windows Windows 10 WooCommerce WooCommerce Sortierung WordPress

Letzte Kommentare

  • Thomas bei WordPress: Einzelne Kategorien aus dem RSS Feed ausschließen
  • Bernhard bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • Bernhard bei CSS: Automatische Silbentrennung in einzelnen Wörtern verhindern
  • MC bei PHP: Boolesche Werte (Boolean Values)
  • eno bei Zufällige Produktanordnung beim Featured Product Slider (PrestaShop 6.1.11 / Megashop Theme)

Informationen

  • Kontakt
  • Datenschutzerklärung
  • Impressum
  • Kontakt
  • Datenschutzerklärung
  • Impressum