WordPress wp_get_attachment_thumb_url full
Try this in the foreach loop: $thumb_url = wp_get_attachment_image_src( $attachment->ID, ‘full’ ); And this for the img src: echo $thumb_url[0];
Try this in the foreach loop: $thumb_url = wp_get_attachment_image_src( $attachment->ID, ‘full’ ); And this for the img src: echo $thumb_url[0];
The problem is in your tax_query terms parameter. Try: ‘tax_query’ => array( array( ‘taxonomy’ => ‘listings_tags’, ‘field’ => ‘slug’, ‘terms’ => $custom_term->slug, ), ), And if you want posts from just basic, there’s no need for getting terms and loopin through. All you can do is WP_Query with tax_query terms parameter as ‘basic’.
Revised Answer ( PS: I actually wanted to revise this answer long ago, but eventually I kept forgetting to do so. 🙂 ) So in this revised answer, the main point is the first one below, but I hope the rest also help you: What you’re trying to do is not going to be (easily) … Read more
I don’t like using categories for this, as they are supposed to be semantic terms. I do, however, like the idea of the global array. Instead of creating a new query directly, I will filter it through a function that will add the results to a global array and return the results: I add this … Read more
Try this: <ul> <?php global $post; $args = array( ‘numberposts’ => 5, ‘category’ => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href=”https://wordpress.stackexchange.com/questions/12234/<?php the_permalink(); ?>”><?php the_title(); ?></a> – <?php the_date(); ?></li> <?php endforeach; ?> </ul> More info: query_posts()
I had to use the WP_Query class: $the_query = new WP_Query(array( ‘category_name’ => ‘Recipe of the Week’, ‘offset’ => 1 ) And then reference my new query object in the template like this: <?php while ( $the_query-> have_posts() ) : $the_query->the_post(); ?>
How about this: $my_query = new WP_Query(array( ‘post_type’=> ‘custom_type’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘my_custom_field’, ‘meta_value’ => ‘custom field value’ )); if($my_query->have_posts()): while($my_query->have_posts()):$my_query->the_post(); //All the post stuff here. endwhile; endif; wp_reset_postdata(); Check this out.
See When should you use WP_Query vs query_posts() vs get_posts()? For a custom post type or a simple page you don’t need query_posts(). Usually, you almost never need it, because it will replace the default query which leads to some counter-intuitive side effects. When in doubt use get_posts().
You shouldn’t use $_GET[‘s’] directly like that, and you definitely shouldn’t use query_posts, although I understand using it for testing. If you’re going to build your own search mechanism in this way, then you should run $_GET[‘s’]through the urldecode() function first, to make sure it doesn’t contain weird data that you might not expect and … Read more
You have the value of posts per page in single quotes, remove the quotes and it will work. That said, you should be altering the main query with pre_get_posts instead of query_posts.