5 blogs on one WordPress site

If you don’t want to use Multisite, yet still want to have multiple blogs with a common backend, another idea is: Customize your theme’s Author Templates so each author’s “blog homepage” has a distinct design Create several different stylesheets, one per author. Use some conditional logic to display the appropriate stylesheet when viewing an individual … Read more

Different template for subcategories

The template hierarchy has filters for all types of templates. Here we can use category_template, check if the current category has a parent, and load the subcategory.php file in that case: function wpd_subcategory_template( $template ) { $cat = get_queried_object(); if ( isset( $cat ) && $cat->category_parent ) { $template = locate_template( ‘subcategory.php’ ); } return … Read more

Wrap Post count in a span

adding a filter to functions.php of your theme is one possibility: add_filter(‘wp_list_categories’, ‘cat_count_span’); function cat_count_span($links) { $links = str_replace(‘</a> (‘, ‘</a> <span>(‘, $links); $links = str_replace(‘)’, ‘)</span>’, $links); return $links; } this would add the spans to any occurrence of ‘wp_list_categories()’ site wide. or change your code into: $args = array( ‘hide_empty’ => FALSE, ‘title_li’=> … Read more

WordPress and isotope filtering

Not sure you got Isotope and filters working yet ?? There are 2 things I think you missed the Filters need to be wrapped in a class (so that the jquery can be actioned by the click on the a links) like so: <ul id=”options”> <li><a href=”#” data-filter=”*”>show all</a></li> <li><a href=”#” data-filter=”.web”>web</a></li> <li><a href=”#” data-filter=”.mobile”>mobile</a></li> … Read more

How to get primary category name in WordPress new version

I have editted the MMT Designer function. This works better for me: if ( ! function_exists( ‘get_primary_taxonomy_id’ ) ) { function get_primary_taxonomy_id( $post_id, $taxonomy ) { $prm_term = ”; if (class_exists(‘WPSEO_Primary_Term’)) { $wpseo_primary_term = new WPSEO_Primary_Term( $taxonomy, $post_id ); $prm_term = $wpseo_primary_term->get_primary_term(); } if ( !is_object($wpseo_primary_term) || empty( $prm_term ) ) { $term = wp_get_post_terms( … Read more

How can I get category ID by category name?

The only alternative I know of (using core functions) is: // Get terms whose name begins with “my_name” get_terms( ‘category’, array( ‘name__like’ => ‘my_name’ ) ); // Get terms whose name contains “my_name” get_terms( ‘category’, array( ‘search’ => ‘my_name’ ) ); If you need an exact match, you’ll have to execute a custom query. $wpdb->get_results( … Read more

Display all posts from all categories with pagination

To be able to order by category, you have to intercept the MySQL Query. Start with pre_get_posts: add_action(‘pre_get_posts’,’setup_my_query_interception’); function setup_my_query_interception($query){ if(!is_admin() && $query->is_home() && $query->is_main_query()){ add_filter( ‘posts_clauses’, ‘order_by_category_intercept_query_clauses’, 20, 1 ); } } Now we enhance the MySQL Query to include the term and taxonomy tables: function order_by_category_intercept_query_clauses($pieces){ global $wpdb; $pieces[‘join’].=” LEFT JOIN $wpdb->term_relationships trt … Read more

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