Loop through all media library images and return those where caption contains the text carousel

Im new to WordPress but I’m looking for a way to loop through all the images that have been uploaded to the media library and output the SRC, description and caption of the image when the caption contains the word ‘carousel’. Is this possible? 1 Answer 1 You could do this pretty easily with a … Read more

Why is the first query affecting the second query, even after wp_reset_query() and wp_reset_postdata(), but not on the second page?

I am literally clueless as to why the code does not function properly on the first page, but functions as expected on the second page. The second query should return the latest 3 posts in the pagination loop, yet it also returns posts from the first query. Instead of 3 posts on the homepage, there … Read more

All posts are still shown when adding category argument to query

I’ve got the following code in my team-type.php file which I’m using to create a custom taxonomy for a member information: function create_team_taxonomies() { $labels = array( ‘name’ => _x( ‘Kategooriad’, ‘taxonomy general name’ ), ‘singular_name’ => _x( ‘Kategooria’, ‘taxonomy singular name’ ), ‘search_items’ => __( ‘Otsi kategooriatest’ ), ‘all_items’ => __( ‘Kõik kategooriad’ ), … Read more

Why we use if with while loop?

if(have_posts()): while(have_posts()): the_post(); the_content(); endwhile; endif; Without if condition this below code also works fine: while(have_posts()): the_post(); the_content(); endwhile; Thanks. 2 Answers 2 You only need the if ( have_posts() ) : if, as the name of the function suggets, you need to do something different if you don’t have posts. This would be something … Read more

Formating the display of a post’s date, outside the Loop

I’m using this function to be able to retrieve several data, from outside the Loop: function get_post_data($postId) { global $wpdb; return $wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE ID=$postId”); } … and then, this to display the date a post was published: <?php global $wp_query; global $thePostID; $thePostID = $wp_query->post->ID; $data = get_post_data($thePostID); echo $data[0]->post_date; ?> wich … Read more

Show scheduled posts in archive page

I’d like my archive.php page’s daily view (is_day) to display scheduled posts (post_status=future). For example, if I go to mysite.com/2011/05/20 I would see all posts scheduled to appear on May 20. The archive page’s loop starts with: if ( have_posts() ) the_post(); and ends with: rewind_posts(); get_template_part( ‘loop’, ‘archive’ ); Do I need to make … Read more