Add Class according to the order of appearance

Just create an array with your classes and loop through alongside with the main loop: function custom_top_products() { $classes = array( ‘first’, ‘second’, ‘third’, ‘fourth’, ‘fifth’ ); $classes_count = count( $classes ); $posts = new WP_Query( array( ‘post_type’ => ‘products’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘comment_count’, ‘posts_per_page’ => 5 ) ); $i = 0; ?><div … Read more

How to selected value default in option list?

should be selected=”selected” NOT “selected=selected” EDIT: Ok I see – it’s because you are using a foreach arguement to say that it’s selected. Meaning that it prints the HTML showing that everything should be selected. Try something like this: <select name=”pais” class=”pais-select”> <option value=”” disabled selected>País</option> <option value=”Argentina”>Argentina</option> <?php $pais = diretorio_request(‘pais’); foreach(diretorio_countries() as $country) … Read more

Grab all Custom Posts by multiple taxonomies and terms

$terms = get_terms(‘location’, array(‘orderby’ => ‘date’, ‘order’ => ‘ASC’)); foreach( $terms as $term ) { $args = array( ‘post_type’ => $post_type, ‘orderby’ => ‘date’, ‘order’ => ‘ASC’, ‘ignore_sticky_posts’ => 1, ‘post_status’ => ‘publish’, ‘posts_per_page’ => – 1, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘organize’, ‘field’ => ‘slug’, ‘terms’ => array( ‘aba-therapist’ ) … Read more

Use different post formats on different post types

This should get you going in the right direction. Not my solution, slightly modified from here. You’ll need to swap out your-post-type for the post type you’re using. function adjust_post_formats() { if (isset($_GET[‘post’])) { $post = get_post($_GET[‘post’]); if ($post) $post_type = $post->post_type; } elseif ( !isset($_GET[‘post_type’]) ) $post_type=”post”; elseif ( in_array( $_GET[‘post_type’], get_post_types( array(‘show_ui’ => … Read more

Multi Parameter search with custom post type category and tag

Ok i manged to create the solution by finding that LIKE condition can be used in meta query. so here is the final code.. $args=array( ‘post_type’ => ‘tyre’, ‘post_status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘tyre-category’, ‘field’ => ‘ID’, //can be set to ID ‘tag’ => ‘ID’, //can be set to ID ‘terms’ … Read more

Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?

Your problem has nothing to do with the_excerpt(). the_excerpt() template tag does not change its behavior by itself or change its behavior according to location. The only time the_excerpt() changes its behavior is when you manually filter the output through a custom function. I most probably think that all of your misery is caused by … Read more