WP_Query on custom field and order results

Change your code with this and might help you with what you are looking for. The issue here is that we cannot include key, order and orderby in meta_query. But if you want to order you result posts based on key than you can pass the query arguments as below: $custom_query_args = array( ‘post_type’ => … Read more

Pagination is broken and I need help fixing it

I’m not sure why the first page works but the second doesn’t, though this may be a hint toward the problem. Toward the bottom of the category template page you have the following: if (function_exists(custom_pagination)) { custom_pagination($custom_query->max_num_pages,””,$paged); } If you review the above, there is a variable called $custom_query. This looks like it’s a WordPress … Read more

Related posts loop based on tags AND categories doesn’t work without at least one tag assigned

You haven’t accounted for the case that there are no tags assigned in your declaration of $tag_related_posts. Your get_posts function always returns results in your line of code: $tag_related_posts = get_posts(‘exclude=” . $post->ID . “&numberposts=” . $max_articles . “&tag=’ . $tags_string); If the $tags_string is null, it just returns a random list of posts and … Read more

multiple if statements [closed]

Each of your if statements have the same has_term(‘NBS_CONS’, ‘broad_type_nbs’ ) function. This could be put in a variable for reuse instead. & Your argument for each if statement is actually very consistent, so much so you could probably reduce it by just putting your varying data in an array, loop though, and use Variable … Read more

Removing the_content() from the page

If you look at the codex (here) you’ll see that the_content() is just a wrapper for get_the_content() which passes it through the the_content filter. So, you too can hook into that filter to change your content output without having to edit the theme files.

Filter post by current 2 differents users id

Based on wordpress reference for WP_QUERY you can use author__in to filter by more than one author. It uses an array of user ids. Here is your code with the needed changes: function list_cpt_by_author_id(){ $user = get_current_user_id(); $authors_id = array(“1”, $user); $custom_terms = get_terms(‘custom-tax’); foreach($custom_terms as $custom_term) { wp_reset_query(); $args = array( ‘post_type’ => ‘artigos’, … Read more