Category: Code

WP_Query – Order by multiple custom fields

The Code $args = array( ‘post_status’ => ‘publish’, ‘post_type’ => ‘board’, ‘meta_query’ => array( ‘last_name’ => array(‘key’ => ‘last_name’), ‘first_name’ => array(‘key’ => ‘first_name’), ),’orderby’ => array( ‘last_name’ => ‘ASC’, ‘first_name’ => ‘ASC’ ), ‘nopaging’ => true ); $query = new WP_Query( $args ); if ( $query->have_posts() ) : while…

Modifying WordPress excerpts

When displaying links to your posts, it’s helpful to display a short excerpt so your readers can quickly get an overall idea of the article. The built in function to display the excerpt defaults to a certain number of words and displays a “Continue Reading” link at the end. Both…