Tuesday, 12 September 2017

Add multiple categories to body class Wordpress

SOLUTION
You can add this code to your custom functions.php file:
function add_categories( $classes = '' ) {

    $categories = get_the_category();
    foreach( $categories as $category ) {
    $classes[] = 'category-'.$category->slug;


}
 return $classes;
}
add_filter( 'body_class', 'add_categories' );

4 comments:

  1. <?php

    /**

    * Child theme functions

    *

    * Functions file for child theme, enqueues parent and child stylesheets by default.

    *

    * @since 1.0.0

    * @package History

    */



    // Exit if accessed directly.

    if ( ! defined( 'ABSPATH' ) ) {

    exit;

    }



    if ( ! function_exists( 'history_enqueue_styles' ) ) {



    // Add enqueue function to the desired action.

    add_action( 'wp_enqueue_scripts', 'history_enqueue_styles' );



    /**

    * Enqueue Styles.

    *

    * Enqueue parent style and child styles where parent are the dependency

    * for child styles so that parent styles always get enqueued first.

    *

    * @since 1.0.0

    */

    function history_enqueue_styles() {


    // Enqueue Parent theme's stylesheet.

    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );

    // Enqueue Child theme's stylesheet.

    // Setting 'parent-style' as a dependency will ensure that the child theme stylesheet loads after it.

    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' ) );
    wp_enqueue_style( 'main-style', get_stylesheet_directory_uri() . '/css/main.css');

    }

    }

    ReplyDelete
  2. https://egghead.io/lessons/angular-2-create-a-simple-angular-2-component

    ReplyDelete
  3. http://jsfiddle.net/shrinivas93/1gt1Lzr6/5/

    ReplyDelete
  4. /*Price Sort*/
    function alter_query_so_15250127($query) {
    if ( !is_admin() && $query->is_main_query() && is_archive()) {

    $query->set('post_type','listings');
    $query->set('meta_key', 'price_value');
    $query->set('orderby', 'meta_value_num');
    $query->set('order', 'DESC');

    }
    }
    add_action('pre_get_posts','alter_query_so_15250127');

    ReplyDelete

Google Map Filter Api Example

Here is Google Map Filter Api Example: