Indenting Category list

$args = array( ‘type’ => ‘post’, ‘hide_empty’ => 0, ‘hierarchical’ => 1, ‘taxonomy’ => ‘category’, ‘pad_counts’ => false ); $categories = get_categories($args); foreach($categories as $category) { echo ‘<tr>’; if($category->parent != 0){ // If this is a subcategory echo “<td>&nbsp;&nbsp;$category->name</td>”; } else { echo “<td>$category->name</td>”; } echo “<td><input type=”text” name=”$category->cat_ID”/></td>”; echo ‘</tr>’; }

Custom loop by url

You can customise the loop query to get results based on a search term – with $s being the search term; <?php // Post Query $args=array( ‘s’ => $s, ); ?> <?php query_posts($args); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

list taxonomy based on taxonomy

If you are trying to print children of a category, this should be sufficient: <?php wp_list_categories(‘orderby=id&show_count=1&use_desc_for_title=0&child_of=”.$term_id); ?> Details here: http://codex.wordpress.org/Template_Tags/wp_list_categories

Exclude Category From Home Page, Display Posts on It’s Own Page?

Rather than performing a separate query, to exclude a category (or any other taxonomy) term, you can hook into pre_get_posts: add_action(‘pre_get_posts’, ‘wpse41820_exclude_cat_from_front_page’); function wpse41820_exclude_cat_from_front_page( $query ){ if( $query->is_main_query() && is_front_page() ){ $tax_query = array(array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => array( 57 ), ‘operator’ => ‘NOT IN’ )); $query->set(‘tax_query’,$tax_query); } return $query; } … Read more

Way to show content of a post, but if exceeds character limit revert to excerpt?

replace the_content(); with echo wpse_limit_content(); function wpse_limit_content() { $content = $post->post_content; $MAX_LENGTH = 100; if ( strlen( $content ) <= $MAX_LENGTH ) return apply_filters(‘the_content’, $content ); $s2 = substr( $content, 0, $MAX_LENGTH ); $s3 = preg_split( “/\s+(?=\S*+$)/”, $s2 ); $s4 = $s3[0]; return apply_filters( ‘the_excerpt’, $s4 ); } If the string is to long it … Read more

How to create category page

You’ll want to stick something like this in your theme’s category.php file: <?php // fetch the categories with the parent being the current cat $sub_cats = get_terms(‘category’, array( ‘parent’ => get_queried_object_id() )); if(!is_wp_error($sub_cats) && $sub_cats) { foreach($sub_cats as $cat) { // Create your grid here, this is just an example printf( ‘<a href=”https://wordpress.stackexchange.com/questions/57529/%s”>%s</a>’, get_term_link($cat, $cat->taxonomy), … Read more

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