Linked Questions

161
votes
5answers
159k views

When to use WP_query(), query_posts() and pre_get_posts

I read @nacin's You don't know Query yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using query_posts() for all my querying needs. Now I'm a little bit ...
19
votes
5answers
18k views

get_terms by custom post type

I have two custom post types 'country' and 'city' and a shared taxonomy 'flag'. If I use: <?php $flags = get_terms('flag', 'orderby=name&hide_empty=0'); I get a list of all terms in the ...
0
votes
3answers
4k views

Querying custom post type twice on same page

I am trying to make a page that displays a Custom Post Type. I need for all post to be displayed twice. Once at a list of products and once as a modal. I am able to display the product list on the ...
-1
votes
3answers
7k views

Using PHP for background-image property [closed]

I'm building a gallery page for a website and want to use the images from post types as background images with lightboxes. The code im using currently is this: <div id="primary" class="content-...
1
vote
1answer
1k views

Is there any need to use both wp_reset_postdata and wp_reset_query together?

Is there any need to use both wp_reset_postdata() and wp_reset_query() together? Is it a case that I would pick one of the two functions; is there any point in doing this after a query : ...
1
vote
1answer
1k views

WordPress get_template_part() function not working

I'm using get_template_part() function on my file (page-home.php) like page-home.php and it is working fine until I called it 5 times on the same file (page-home.php) but when I called it 6th times ...
1
vote
1answer
949 views

WP_Query, pre_get_posts and offset

I can't get my head around, why offset seems to be forwarded from custom WP_Query in page template to the main query further down?! From my functions.php /** * ::: Filter 'Custom Post Type' Archive ...
0
votes
1answer
1k views

Can't get the_content to show

I'm using the following code to get posts from a category in a page. This category uses ACF for some fields. However, when I try to output everything, it shows everything but the_content. For better ...
0
votes
2answers
97 views

Running Filter or Shortcode Before Query Prevents Excerpt from Showing

I've been wrestling with some code cobbled together for a function I found, first published circa 2009 and my inexperience with PHP has me at a loss. The function is designed to count episodes in a ...
0
votes
1answer
72 views

How to hide post in WordPress

I followed the guidelines of this article to create a featured post, but it displayed two similar posts: 1 featured post and 1 new post. I want to hide that article when it is used as a featured post. ...
0
votes
1answer
79 views

How to use multiple paginate_links() in my index.php?

I've created two divs which displays posts from two different categories. The paginate_links() function works only for the first div and not for the second. I tried @Boone Gorges answer: Multiple ...
2
votes
1answer
48 views

wordpress query in header won't reset and corrupts other loops

In a template part in my header, I have the following code: $args = array('post_type'=>'weather_today','orderby'=>'ID','order'=>'ASC','posts_per_page'=>1); $query = new WP_Query($args); $...
-1
votes
2answers
38 views

Bug with post titles [closed]

My post titles are displaying the title of the media (image) rather than the title of the post. WP V4.8 using postgrid for posts; deactivated this, issue still occurs deactivated current theme; ...