Why does my category page display “posted on…” when all I want it to do is display categories?

Open the archive.php file of the Blank theme and delete this code from the top. <?php /* If this is a category archive */ if (is_category()) { ?> <h2>Archive for the &#8216;<?php single_cat_title(); ?>&#8217; Category</h2> <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> <h2>Posts Tagged &#8216;<?php single_tag_title(); ?>&#8217;</h2> … Read more

Display category tree of a post in search results

i am missing some details but here is the code for this string “category level 1-> level 2 -> level3″… i also included the search term as the title and the loop around it.. <h1><?php echo ‘Search Results For:’. get_search_query(); ?></h1> <ul> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $category = get_the_category(); … Read more

How to Organize my Photo Albums?

General idea based on the use of regular Posts, not Custom Post Types (which is what the plugin CPT-UI is about): one parent Category -Photos under it, the needed sub-categories -Personal, Professional, etc one post corresponds to one Album -Vacations 2012, News Coverage, etc upload all images of the Album into the post, put titles, … Read more

WooCommerce Product Search Error

” Invalid argument supplied for foreach()” . means that the $parents variable is not an array so you can’t loop through it. You should wrap the foreach loop in an if check that verifies that $parents is something valid. <?php $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); $parents = get_the_terms($term->parent, get_query_var(‘taxonomy’) … Read more

Replace the post count on wp_list_categories with “Has Posts” instead of number and “No Posts” if none

Add the below in your theme’s functions.php. It should work the way you want function my_list_categories( $output, $args ) { $output = str_replace( ‘(0)’, ‘(No Posts)’, $output ); $output = preg_replace( ‘/\((\d+)\)/’, ‘(Has Posts)’, $output ); return $output; } add_filter( ‘wp_list_categories’, ‘my_list_categories’, 10, 2 );

Get all first images of posts in same category

You can do this, and it isn’t that hard though could be a lot of work for the server. The code, a bit simplified, should look something like this: $cposts = wp_list_pluck($wp_query->posts,’ID’); // var_dump($cposts); // debug $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ =>’image’, ‘post_status’ => ‘inherit’, ‘order’ => ‘DESC’, ‘posts__in’ => $cposts ); // … Read more

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