Custom Select Query – Selecting the Year?
Don’t use the direct SQL query, there’s no point and it’s bad practice. Instead use WP_Query: $year = date(‘Y’); $query = new WP_Query( array( ‘year’ => $year, ‘post_type’ => ‘news’ ) );
Don’t use the direct SQL query, there’s no point and it’s bad practice. Instead use WP_Query: $year = date(‘Y’); $query = new WP_Query( array( ‘year’ => $year, ‘post_type’ => ‘news’ ) );
I think you can use the_attachment_link or wp_get_attachment_link. http://codex.wordpress.org/Function_Reference/wp_get_attachment_link http://codex.wordpress.org/Function_Reference/the_attachment_link Example the_attachment_link( $photo->ID, false, false, true );
Something like this: Make an URL like /companies/?leaders Than in your archive template (top): if(isset($_GET[‘leaders’])) { global $query_string; $query_string = $query_string . ‘&meta_key=leaders&meta_value=yes’; query_posts($query_string); } Hope this helps.
I’m assuming there is an option in the array that is meant to receive an array of options for the checkboxes…? In which case, you can use get_posts to obtain an array of post objects (of which ever type), and then loop through this, to create an array of post titles: For example.. $args=array(‘numberposts’=>-1,’post_type’ => … Read more
Yup. You’ll need to get/set $paged with your query, like so: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘numberposts’ => 15, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_parent’ => $post->ID, ‘paged’ => $paged ); ?> <?php $photos = new WP_Query($args); ?> <?php if ( $photos->have_posts() … Read more
Try out this code and see if it works for you, I just cooked it up real quick and haven’t tested it, so it may be way off base, but the concept is there. $tax_args = array( ‘public’ => true ); $taxonomies = get_taxonomies( $tax_args, ‘names’, ‘or’ ); $term_args = array( ‘fields’ => ‘ids’ ); … Read more
Remember: custom page templates are still static Pages, so the default Loop for a custom page template will be the post content of the static page to which the template is assigned. You need to add a custom query to the template, in order to query anything other than the default query. Refer to the … Read more
I think it would be better to just do a second query if you don’t have 8 posts for that month, for example: //get current date $date = getdate(); //setup args $args = array( //basic stuff ‘posts_per_page’ => -1, ‘post_stutus’ => ‘publish’, //time parameters ‘year’ => $date[‘year’], ‘month_num’ => $date[‘mon’] ); //create WP_Query $my_query = … Read more
Look at the meta_query argument, and the “IN” option for the “Compare” operator. Your query would look something like: $args = array( ‘product’ => $product, ‘meta_query’ => array( array( ‘key’ => ‘primary_link’, ‘value’ => array( ‘home’, ‘obj_handling’, ‘standalone_doc’, ‘advantages’, ‘weaknesses’, ‘top_comments’ ), ‘compare’ => ‘IN’ ) ) );
Since you’re using WP_Query(), you should consult the Codex entry for WP_QUery(). It lists all of the parameters that can be passed to the arguments array. In this case, you want to use the post custom meta parameters. Assuming your custom meta key is _show_on_front, and your value is true or false: <?php $custom_query_args = … Read more