Add subcategories posts to the counts column at the admin’s categories list

You can change an array of get_terms() arguments with two filters: get_terms_defaults filters the terms query default arguments; get_terms_args filters the terms query passed arguments. For example, this code will change the default value for the pad_counts parameter for all queries related to categories and called from the administrative part of the site. add_filter( ‘get_terms_defaults’, … Read more

Retrieve posts inside foundation tabs and tab-content split by 3 per row

I managed to ‘solve’ the problem with the code below. It’s not a pretty solution but it does the job. Any adjustments to the code to make it more pretty are welcome. <?php /* Template Name: Page information */ get_header(); ?> <div class=”row”> <div class=”main-wrap” role=”main”> <?php do_action( ‘foundationpress_before_content’ ); ?> <div class=”row”> <div class=”column”><a … Read more

Display number of post published every day

Since the publish date is stored, you can simply range-select count for posts, which are published in a given interval range. function count_posts_per_interval($seconds) { global $wpdb; $count = (array) $wpdb->get_row($wpdb->prepare( “select count(ID) from wp_posts where post_status=”publish” and post_date between date_sub(now(), interval %d second) and now();”, $seconds )); return (int) array_shift($count); } The SQL query can … Read more

Implementation to count page visits of unique visitors based on a cookie

Here’s a minimum working example… (note: this is untested code.) add_action(‘init’, ‘custom_rsvp_handler’); function custom_rsvp_handler() { // for singular posts only // (could also check for event post type here) if (!is_singular()) {return;} // set cookie expiry length (eg. 28 days) $cookielength = time()+(60*60*24*28); // set a cookie key based on post ID global $post; $cookiekey … Read more

Click Count on Download a File

Use this code.. $downloads = $product->get_files(); $product_id = $product->id; foreach( $downloads as $key => $each_download ) { $query = “SELECT SUM( download_count ) AS count FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions WHERE product_id = $product->id”; $count = $wpdb->get_var( $query ); if ( ! empty( $count ) ) { echo ‘<a href=”‘.$each_download[“file”].'”>Download (‘.$count.’)</a>’; } else { echo ‘<a href=”‘.$each_download[“file”].'”>Download</a>’; } … Read more

Modify the category post counting function

When registering a custom taxonomy, register_taxonomy() accepts an update_count_callback argument. This callback function will be called when the count is updated. The default callback is _update_post_term_count() for taxonomies attached to post types, which confirms that the objects are published before counting them. _update_generic_term_count() is the default for taxonomies attached to other object types, such as … Read more

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