Hot answers tagged

2

This is another example of what is by far the most common mistake I've seen in WordPress development. I don't think it's even close to whatever the next most common is. I'm very curious as to what documentation or tutorials are out there that are teaching this approach to queries, or what could be done to the official documentation to make this clearer. The ...


1

That's not what the SEO title does/is for. It appears that you've used the wp_title() function in your template by mistake. wp_title() is intended for use in the <title> tag in the <head> for setting the browser tab/document title. However, since WordPress 4.1 this has been superseded (but not officially deprecated, yet) by add_theme_support( '...


1

I suggest the following: $categories = get_the_category(); $category_ids = wp_list_pluck( $categories, 'term_id' ); $args = [ 'numberposts' => 4, 'category__in' => $category_ids, ]; $related_posts = get_posts( $args ); $related_posts = wp_list_filter( $related_posts, [ 'ID' => get_queried_oject_id() ], 'NOT' ); if ( count( $...


1

As suggested by the default link labels, "Older Entries" and "Newer Entries", get_next_posts_link() and get_next_posts_link() are for outputting links between pages of posts. If you only have 2 posts, and your posts per page setting is set to anything higher than 1, then you're not going to have more than one page of any archive or your blog, so the links ...


1

There are a number of ways you can break this up. I think you have the right idea though to break it inside of your current loop with $i, but maybe something simple that is readable could be changing this: if ($i == 19 OR $i == 31 OR $i == 43) { ?> Into this: if( in_array($i, range(19, 21)) || in_array($i, range(31, 33)) || in_array($i, ...


1

Your query should be something like this: $args = array( 'post_type' => 'post', 'posts_per_page' => 1, 'meta_key' => '<ACF FIELD KEY HERE>', 'meta_value' => date( "Ymd" ), 'meta_compare' => '>', 'meta_query' => array( 'key' => '<ACF FIELD KEY HERE>', 'value' => date( "Ymd" ), ...


1

You can't order by values inside serialised arrays in post meta. When you store an array like this: $value = [ [ 'plan_name' => 'name 1', 'plan_price' => '1', 'theType' => 'yesPaid', 'plan_space' => 'Unlimited', ], [ 'plan_name' => 'name 2', 'plan_price' =...


1

In this line: $cats .= $category->name . ', '; You append a name of category to variable called $cats. But you never reset this variable. So every post appends its categories to the same variable. So here’s how to fix this: <?php $categories = get_the_terms($custom_args->ID, 'veranstaltungen-category'); $cats = ''; // set empty string as ...


Only top voted, non community-wiki answers of a minimum length are eligible