Custom Loop in Page Admin Causing Other Fields to Fail
Switched the loop from using to WP_Query to get_posts.
Switched the loop from using to WP_Query to get_posts.
Have you tried simply omitting the ‘terms’ key from the ‘tax_query’ array? $query03 = array( ‘numberposts’ => 5, ‘post_type’ => array( ‘video’ ), ‘tax_query’ => array( array( ‘taxonomy’ => ‘product’, ‘field’ => ‘slug’ ) ) ); Alternately, I wouldn’t really worry about the weight of the query. The resulting query will be what it will … Read more
Yes, use caching. But even with caching you should rethink what you are actually doing because the cache for page/2 should change every time you publish a new post which might make caching pointless depending on the amount of traffic to that page. You should probably rethink what you are trying to achieve there, why … Read more
From get_media_items function and his code, you can use get_children adding mime type for images: $images = get_children( array( ‘post_parent’ => $post_id, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order ASC, ID’, ‘order’ => ‘DESC’) ); That will get you an array ($images) of images attached to $post_id. In you case, if you’re inside … Read more
Finally I’ve figured out the correct coding for this problem: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $wp_query = new WP_Query(); $wp_query->query(‘tag=concurs&posts_per_page=”.get_option(“posts_per_page’).’&paged=’ . $paged); ?> <?php if ($wp_query->have_posts()) : ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> [code for title, author, category, meta-info etc] <?php endwhile; ?> <div class=”next-prev”><?php posts_nav_link( ‘ ‘, ‘<img … Read more
In pure SQL you can use comma separated strings to do what you want– that is, something like ORDER BY post_type,post_name,post_date. However, WP_QUERY will not allow that kind of thing to pass through. There is a rigid set of allowed values. There are a couple of ways I can think of to do this. You … Read more
You cannot declare multiple functions with same name in PHP. Codex examples for this are technical demonstration, rather than ready-made usable snippet. Give your filter functions unique names, that are not likely to clash with your own or third party code.
So after some more digging was able to figure it out. Using the Advanced Custom Fields plugin, I created a text field that appears on attachments with specific tag applied to them. Now you can assign a value and I updated my WP_Query to reflect: <?php $args = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘posts_per_page’ => … Read more
Add this to a plugin or your active themes functions.php function my_custom_display_topic_index_query () { $args[‘orderby’] = ‘date’; $args[‘order’] = ‘DESC’; return $args; } add_filter(‘bbp_before_has_topics_parse_args’, ‘my_custom_display_topic_index_query’ );
From a naming standpoint it seems that the term “filter” would be more appropriate since you are filtering by criteria first and then a sort (directional) is applied when you order. But that’s more a naming convention standpoint… From a code structure if you are using the check_for_popular() method in several places then it makes … Read more