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 add a box for list items?

If you want to create an option page with image upload/select fields you can use the Option Framework plugin. It is straighforward and easy to use for anyone. If you want to add upload/select fields to a wordpress page or post use Custom Fields Creator or the more powerful plugin: Advanced Custom Fields. NB you … Read more

List products from current category

Your best bet to do this would be to add a filter/hook on the specific tag. See this snippet at the WooCommerce API docs site on excluding a category for the proper format and to get going in the right direction. http://wcdocs.woothemes.com/snippets/exclude-a-category-from-the-shop-page/ But if you want a down and dirty way to filter for a … Read more

Add thumbnails in ‘li’ list

If this is a post loop can’t you just put your images in li’s within the editor. Just select them and put them into a bulleted list.

How to make a list of posts displaying them 5 by 5 with a “next posts” link?

I found the actual answer in a stackoverflow question. Quoted from the answer: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 10, ‘paged’ => $paged ); $wp_query = new WP_Query($args); while ( have_posts() ) : the_post(); ?> <h2><?php the_title() ?></h2> <?php endwhile; ?> <!– then the pagination … Read more

Split custom post list into two columns

You could count the number of items and insert </ul><ul> after 50%. Sample code, not tested: if ($postslist) { $count = 1; if($top) echo ‘<h4>’.$name.'</h4>’; echo ‘<ul>’; foreach ( $postslist as $post ) { echo ‘<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title($post->ID).”</a></li>”; if ( 0 === $count % 10 ) echo ‘</ul><ul>’; $count += 1; } echo ‘</ul>’; } And … Read more

Listing category

If you know the depth that you want you can add a depth parameter to $args $args = array( ‘orderby’ => ‘id’, ‘show_count’ => ‘0’, ‘child_of’ => $this_category->term_id, ‘use_desc_for_title’ => ‘0’, ‘taxonomy’ => ‘product_cat’, ‘hide_empty’ => ‘0’, ‘child_of’ => $this_category->term_id, ‘depth’ => 2 ); wp_list_categories($args); Experiment with that number if it isn’t what you want. … Read more

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