Author: Nicholas Rowe
-
Change the default excerpt length of 55 words.
By default the_excerpt length is 55 words. Sometimes I want to give my readers a longer excerpt length, depending on font-size and other element sizes, you could make the little teaser somewhat longer. The below code creates overwrite the_excerpt and will return as many words as you desire. [php]function new_excerpt_length($length) { return 100; } add_filter(‘excerpt_length’, ‘new_excerpt_length’);[/php] Change…
-
When to use WP_Query, query_posts and pre_get_posts
query_posts() function is commonly thought of as the simplistic and problematic way forward to modify a main query of a page by replacing it with a new instance of the particular query. It is bad practice as it re runs SQL queries and will simply not work and fail in some circumstances, this usually happens when…