Order Categories by Character Count

This is probably more a question about PHP rather than WordPress, and as such may be closed as off-topic for this site. That said, you can usort() to sort an array using a custom comparison function: usort( $listings->loop[‘cats’], function( $a, $b ){ return strlen( $a->name ) – strlen( $b->name ); } ); After the call … Read more

AZ Directory posts directory index

It’s easy if all posts are shown on the same page, then you can do: $AZposts = get_posts(array( ‘numberposts’ => -1, ‘post_type’ => ‘post’, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘category’ => $cat )); $current = “”; $nav = “”; $postlist = “”; foreach($AZposts as $AZpost) { $firstletter = strtoupper(substr($AZpost->post_title,0,1)); if($firstletter != $current) { $postlist … Read more

Open everything in new tab

Looks like you are talking about the_excerpt. Following code will work, as you are looking for it: function custom_excerpt($more) { global $post; return ‘<a class=”moretag” target=”_blank” href=”‘. get_permalink($post->ID) . ‘”> Continue reading…</a>’; } add_filter(‘excerpt_more’, ‘custom_excerpt’); You will need to put it in your functions.php file.

How to delete categories in WordPress

To delete a category from WP , first you need to open the category listing. It will come when you will mouse over the Posts. Once you click on Categories, it will display all the categories. Then mouse over to the category which you want to delete and it will show you an Delete link. … Read more

How do you get parent and grandparent categories [duplicate]

This query will help you global $wpdb; $cat_id = 65; // this query will get parent relationships from term_taxonomy table and get category names from terms table $category = $wpdb->get_row( “SELECT t4.term_id as parent_id, t4.name as parent_name, t5.term_id as grandparent_id, t5.name as grandparent_name FROM `{$wpdb->prefix}term_taxonomy` t1 left join `{$wpdb->prefix}term_taxonomy` t2 on t2.term_id = t1.parent left … Read more

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