get post excerpt by query
You’re querying post_content but selecting post_excerpt. These two things are not the same. Perhaps the text you are searching for is in more than one post?
You’re querying post_content but selecting post_excerpt. These two things are not the same. Perhaps the text you are searching for is in more than one post?
This could be a simple PHP issue of how you are asking to return the first date() date(‘M’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); is returning Dec, and WP_Query needs the month number. First, try changing ‘M’ to ‘m’. date(‘m’, mktime(0, 0, 0, date(‘m’), 0, date(‘Y’))); If that doesn’t work, try using the date_query and … Read more
Using categories isn’t the same as using a custom taxonomy. You should adapt your code to use get_terms and to query for your custom tax: $categories = get_terms(‘article’); foreach($categories as $category) { $args=array( ‘article’=>$category->slug, ‘post_type’ => ‘journal’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1); }
Post per page not working
Thank you to Milo for pointing me to the pre_get_posts hook. That was exactly what I needed. Here is my updated code: Archive page code <?php get_header(); get_template_part( ‘include/content’, ‘head’ ); ?> <div class=”postcontent nobottommargin<?php if( semi_option( ‘blog_sidebar’ ) == ‘left’ ) { echo ‘ col_last’; } ?> clearfix”> <?php if ( have_posts() ) : … Read more
Is their anyway we can do the filtering (i.e comparing 3 values) in wp_query itself? What you are asking is tricky in pure SQL, though it can be done. WP_Query cannot handle the logic natively, though. You would have to create one or more filters. Doing this with the data structure you have right now … Read more
As far as I know, you can’t actually publish a post without a title. WP might erroneously say your posts are published, but I’m pretty sure they’re still viewed as drafts, which is why you don’t get any post results. First, make sure your custom post type supports your custom field: $args = array( ‘post_type’ … Read more
Try this: <?php $querydetails = ” SELECT wposts.* FROM $wpdb->posts wposts INNER JOIN ( SELECT post_id FROM $wpdb->postmeta wpostmeta WHERE ( ( wpostmeta.meta_key = ‘type’ AND wpostmeta.meta_value LIKE ‘%Collection1%’ ) OR ( wpostmeta.meta_key = ‘type’AND wpostmeta.meta_value LIKE ‘%Collection2%’ ) OR ( wpostmeta.meta_key = ‘type’AND wpostmeta.meta_value LIKE ‘%Collection3%’ ) OR ( wpostmeta.meta_key = ‘type’AND wpostmeta.meta_value LIKE … Read more
OK here’s an attempt, however I don’t know the exact structure of your categories taxonomy so it may need some slight tweaking. I’ve updated the HTML of your form so it uses the values selected by the user, then there’s a block of PHP code which runs a custom WP_Query to display the relevant posts … Read more
You don’t need to loop over each category & query them one-by-one, just query them all once: $query = new WP_Query( array( ‘post_type’ => array( ‘service’ ), ‘category__in’ => $ucategory, ‘posts_per_page’ => -1, ) );