Change Post Class function

post_class() is a wrapper around get_post_class(). Try the following hook post_class which is fired from get_post_class() within wp-includes/post-template.php: add_filter(‘post_class’, ‘filter_post_class’, 10, 3); function filter_post_class($classes, $class, $post_id) { $temp = implode(‘ ‘, $classes); $temp = preg_replace(‘/\s\btag\-\w*\b/i’, ”, $temp); return explode(‘ ‘, $temp); } Alternatively (RECOMMENED): add_filter(‘post_class’, ‘filter_post_class’, 10, 3); function filter_post_class($classes, $class, $post_id) { $classes = … Read more

Remove Extra Classes from Post Title

Try this. // **** Remove unwanted classes function remove_classes($classes, $class, $post_id) { // Array that holds the undesired classes $removeClasses = array( ‘category-‘, ‘tag-‘ ); // Array to store the new class names $newClasses = array(); foreach ($classes as $_class) { // Iterate through the array of undesired classes and // check if the current … Read more

add active class based on permalink and url

For the left side you could do this, <?php $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1, ); $loop = new WP_Query( $args ); // add custom function before loop, so you can apply excerpt filter only to this case do_action(‘my_custom_pre_loop_action’); // is url parameter set, if … Read more

How to make classes for posts?

Use ‘post_class‘ for custom CSS per post. An example with 3 variations (only use 1): <div id=”post-<?php the_ID(); ?>” class=”red box” ?>> //idea 1 <div id=”post-<?php the_ID(); ?>” <?php post_class(‘box-color’); ?>> //idea 2 <div id=”box-color” <?php post_class(); ?>> //idea 3 <h3>Header</h3> Content </div> To be able to choose a color in the post, use a … Read more

Output terms to post_class()

The easiest and most straight-forward way to do this would be: $tax_terms = get_the_terms( $post->ID, array(‘genre’) ); $tax_terms = wp_list_pluck($tax_terms,’slug’); post_class(implode(‘ ‘,$tax_terms)); You could also apply a filter to post_class that does essentially the same. function tax_classes_wpse_105386($classes) { global $post; $tax_terms = get_the_terms( $post->ID, array(‘genre’) ); $tax_terms = wp_list_pluck($tax_terms,’slug’); $classes = array_merge($classes,$tax_terms); return $classes; } … Read more

different post-class when template is loaded via ajax

You have to use this format: FUNCTIONS.PHP function theme_name_scripts() { wp_enqueue_script( ‘script-name’, get_bloginfo(‘stylesheet_directory’) . ‘/js/min.js’, array(), ‘1.0.0’, true ); wp_localize_script( ‘script-name’, ‘ajax’, array( ‘url’ => admin_url( ‘admin-ajax.php’ ) ) ); } function ajax_callback() { get_event_list(); } add_action( ‘wp_enqueue_scripts’, ‘theme_name_scripts’ ); add_action(‘wp_ajax_ajax’, ‘ajax_callback’); add_action(‘wp_ajax_nopriv_ajax’, ‘ajax_callback’); AJAX: $.get( ajax.url, { ‘action’: ‘ajax’, ‘order’ : ‘DSC’, }, function( … Read more

How to add class or id to shortcode HTML elements?

You could abandon the shortcodes and use HTML. <div class=”row full-width whatever”> [one_third]1[/one_third] [one_third]2[/one_third] [one_third]3[/one_third] </div> OR you could easily just wrap all of your code in another div and target the [row] element through CSS: <div class=”your_special_wrapper”> [row] [one_third]1[/one_third] [one_third]2[/one_third] [one_third]3[/one_third] [/row] </div> <style> .your_special_wrapper div{ /*whatever css you need*/ } </style>

Adding Filter to Homepage only

Even if wrap your filter in a if statement, the function still will be executed. Try this: global $current_class; $current_class=”flex-container”; function rt_oddeven_post_class ( $classes ) { if ( is_home() || is_front_page() ) { global $current_class; $classes[] = $current_class; $current_class = ($current_class == ‘flex-container’) ? ‘flex-container-reverse’ : ‘flex-container’; return $classes; } } add_filter ( ‘post_class’ , … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)