the_content() in single-{post-type}.php problem

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

category__not_in — anyway to use category name instead of id?

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);

Query for posts in 2 taxonomies

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 ) )

Store loop into array

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

meta_query on a date range using an array of values

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

Exclude filter on front page

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’);