New answers tagged

2

WordPress will cache all terms for taxonomies attached to all post types in the query result set by default - well, so long as you haven't set either cache_results or update_post_term_cache to false (codex). So calling get_the_terms etc. within the loop will not hit the database. However, wp_get_object_terms will hit the database as it by-passes WordPress' ...


0

It might be status issue. Try with: 'post_status' => 'any'


0

Here is another possible solution : $args = array( 'post_type' => 'post', 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => 'karusell' ) )); $posts = get_posts( $args );


0

To get Blog ids you can use: $blogs = wp_get_sites (); $blogs_id = array(); foreach ($blogs as $blog) { $blogs_id [] = $blog["blog_id"]; } instead of: global $wpdb, $blog_id, $post; $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM wp_blogs ORDER BY blog_id" ) );


0

If you are simply trying to echo the excerpt in a specific part of a theme, you can simply use the following code within the loop: <?php $excerpt = get_the_excerpt(); echo substr( $excerpt, 0, 15 ) . '&hellip;'; ?> If you want to filter the excerpt globally (in archives, blog pages, etcetera) to match any post part of one or more ...


0

Put the following code in your functions.php function excerpt($limit) { $excerpt = explode(' ', get_the_excerpt(), $limit); if (count($excerpt)>=$limit) { array_pop($excerpt); $excerpt = implode(" ",$excerpt).'...'; } else { $excerpt = implode(" ",$excerpt); } ...


0

Instead of trying to do this through the orderby parameter, I went a different direction. Logically, the orderby parameter above only applies to the posts within each grouping, not the taxonomy term grouping itself so it won't work for this. What I ended up doing was adding 01, 02, 03, etc. to the taxonomy term name itself, then stripped that out using ...



Top 50 recent answers are included