WordPress Count posts within a custom post type

It looks that this code is very old. Function wp_start() is deprecated since WordPress 1.5 (Documentation). But you wanted to know how it code is counting so: $posts = get_posts(‘numberposts=6&offset=0’); – get 6 posts foreach ($posts as $post) : – iterate over each post static $count1 = 0; – initializes $count1 variable $count1++; – increase … Read more

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

How do I edit the WordPress post.php file?

You’ll want to add a custom meta box, and put your code in the corresponding callback. It sounds like you’ve already set up your custom post type, so just make sure you have the last line to register your meta box callback: register_post_type( ‘wpse_cpt’, array( ‘labels’ => array(‘all’,’the’,’labels’), ‘public’ => true, ‘supports’ => array( ‘title’, … Read more