Trying to display all posts in a category

I don’t know what you tried so far, but below you have a quick answer to list posts from a caategory by its ID. <?php $args = array( ‘posts_per_page’ => -1, // Will show all posts from the category ‘cat’ => 149, // ID of the category ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘post_type’ => … Read more

how to display categories for a specific post?

You can use single_cat_title function to get category’s name. Useful for category template files for displaying the category page title. The prefix does not automatically place a space between the prefix, so if there should be a space, the parameter value will need to have it at the end.

Querying posts from two different categories while looping inside another loop

You should not be using query_posts() for this or anything else. For secondary loops you should be making new WP_Query instances. Since you can (and should) assign instances to different variables they won’t interfere with each other. So your structure would be roughly like this: $outer_query = new WP_Query(); while( $outer_query->have_posts() ) : the_post; $inner_query … Read more

Categories and Tags Conflict after Woocommerce Installation

I was able to resolve this issue by changing the rewrite slug from product-tag to product_tag when registering the taxonomy. It looks like WP does not like the hyphen and prefers the underscore. $args = array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘show_ui’ => true, ‘show_admin_column’ => true, ‘update_count_callback’ => ‘_update_post_term_count’, ‘query_var’ => true, ‘rewrite’ … Read more

Using template file for single post in sub-directory multisite

Use STYLESHEETPATH instead of TEMPLATEPATH. You’ll find the definitions in wp-includes/default-constants.php file. Please have look. So your code block will be like below- //Gets post cat slug and looks for single-[cat slug].php and applies it add_filter(‘single_template’, create_function( ‘$the_template’, ‘foreach( (array) get_the_category() as $cat ) { if ( file_exists(STYLESHEETPATH . “/single-{$cat->slug}.php”) ) return STYLESHEETPATH . “/single-{$cat->slug}.php”; … Read more

How to Change Sort Order of default WordPress Catgory Widgets?

@Sandun why don’t you create your own widget? <?php class Category_List_Custom extends WP_Widget { /** * Sets up the widgets name etc */ public function __construct() { $widget_ops = array( ‘classname’ => ‘category_list_custom’, ‘description’ => ‘Category list custom’, ); parent::__construct( ‘category_list_custom’, ‘Category List Custom’, $widget_ops ); } /** * Outputs the content of the widget … Read more

How to echo Tags and Categories as plain text

Yes, there’s many ways to do it, You must add parameters to the function to override default value, first parameter must be empty the_tags( ” ); echo ‘<meta itemprop=”keywords” content=”‘. the_tags( ”) .””/>’; There is also wp_get_post_terms() function if you want more control, Create a function in functions.php function wpse_get_tags(){ global $post; $term_list = wp_get_post_terms($post->ID, … Read more

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