Display date only once for a each set of posts relating to that date
Just use the_date(), it has this as a built-in feature. See the dev docs for more info.
Just use the_date(), it has this as a built-in feature. See the dev docs for more info.
There’s a third option, creating a front-page.php template file. It’s similar to your option #1, except option #1 includes you creating a Page within the admin, and in your case it doesn’t sound like you need to do so. Option #1 is more appropriate when you also want to manage some of the front page’s … Read more
First of all, you shouldn’t use get_posts on your CPT archive – WP already creates a query and selects posts that should be display in there. So your archive-pjesma.php should look like this: <?php get_header(); ?> <?php while ( have_posts() ) : the_post(); ?> <h2><a href=”https://wordpress.stackexchange.com/questions/326484/<?php the_permalink(); ?>”><?php the_title(); ?></a></h2> <?php // the_content(); ?> <?php … Read more
You can use List Category Posts (Disclaimer: I’m the author of List Category Posts) or you can code this yourself: $category_id = get_cat_ID($category_name); This way you can get the id and exclude it from the loop with the minus sign. Example: get_posts(cat=-1);
You can try this : foreach( $pages as $key => $post ) and : <div class = “event <?php if( $key == ( count( $pages ) – 1 ) ) echo ‘last’; ?>” > It will add a last class to your last event div.
According to the Codex, here’s how you would query posts from several taxonomies: ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘videoscategory’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug ), array( ‘taxonomy’ => ‘yourothertaxonomy’, ‘field’ => ‘slug’, ‘terms’ => $other_custom_term->slug ) )
Try to replace $id[$counter] = get_the_id(); with array_push( $id, get_the_ID() ); to collect the post id’s into the $id array. Update: If you also use $ids instead of $id: $args = array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ‘posts_per_page’ => 5, ‘orderby’ => ‘date’, ‘order’ => ‘desc’); $ids = array(); $products = … Read more
I needed to get post with type event and the custom field “date” later than today, this sample of code worked perfectly for me, I hope it helps to someone in a similar situation. $today = date(“Y-m-d”); $today1 = date(“Ymd”, strtotime(“$today”)); $custom_meta = array( array( ‘key’ => ‘data_de_inicio’, ‘value’=>$today1, ‘compare’=>’>’, ‘type’=>’date’, ), ); $query = … Read more
The ‘the_posts’ filter hook allows you to edit posts that are going to be displayed in a loop. It’s fired for all queries (the main and the secondaries) so you need to check that the query you’re acting on is the right one. That said in your case you can: send a query variable to … Read more
You can just remove the filter before calling the_excerpt and then add it back afterwards… remove_filter(‘excerpt_more’,’new_excerpt_more’); the_excerpt(); add_filter(‘excerpt_more’, ‘new_excerpt_more’);