How to get post with slug and exclude categories

Please read this Codex page why you should not use query_posts(). If you really want to use query_posts(): query_posts( ‘name’ => ‘test’, ‘category’ => ‘-15’ // notice “minus 15” ); The right way to exclude category: $query = new WP_Query( array( ‘name’ => ‘test’, ‘category__not_in’ => array(15) ) ); if ( $query->have_posts() ) { ….. … Read more

Post Title to featured Image ALT

If $size is already an array in your original code as it looks to be, then the argument passed will become array(array(150,150)) instead of just array(150,150) and fail, so you can just do: <?php $title=get_the_title(); the_post_thumbnail( $size, array( ‘alt’ =>$title) ); ?>

WordPress display posts category in loop

The below code check that post have category or not. If post have category then it will display list of category separate by comma. You can try this code. Hope this will help you. if(has_category()) { echo $cats_list = get_the_category_list(‘, ‘); }

Bootsrap carousel for post

You have added active class in all slides. Due to this all slides is displaying. You have to add active class to first slides only. Check below bootstrap slider code- <div class=”carousel-inner” role=”listbox”> <div class=”item active”> <img src=”https://wordpress.stackexchange.com/questions/235599/…” alt=”https://wordpress.stackexchange.com/questions/235599/…”> <div class=”carousel-caption”> … </div> </div> <div class=”item”> <img src=”https://wordpress.stackexchange.com/questions/235599/…” alt=”https://wordpress.stackexchange.com/questions/235599/…”> <div class=”carousel-caption”> … </div> </div> … … Read more

Display Featured Posts Grid on Static Page (Gazette)

Bingo. I added the featured content template (as originally and later suggested by @user53340) to the page.php with a condition so the featured grid would only display on the page I designate. Add to page.php if ( is_page(ID) ) { // Include the featured content template. get_template_part( ‘featured-content’ ); } After changing the front page … Read more

Show posts by quarter

Let’s define a helper function to map a month to a quarter: function wpse_get_month2quarter( $month ) { return ceil( $month / 3 ); } We could then consider what to do with input values that are not integers in the set {1, …, 12}. ps: I got the idea for the formula from this Excel … Read more

Removing all post tags except a given list

Assuming you have a CSV file of your excluded ids and that this file name is exclude_tags.csv the format of that file should be 1,2,3,4 This would represent tags with id 1,2,3 and 4 try this $ wp term list post_tag –exclude=$(cat exclude_tags.csv) –field=term_id | xargs wp term delete post_tag Basically, this will send the … Read more