Questions tagged [query-posts]

Set up The Loop with query parameters. This will override the current WordPress Loop and shouldn’t be used more than once. This must not be used within the WordPress Loop.

238 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
1answer
505 views

Query Custom Meta Value with Increment

I have a Query searching for a meta value I have added to my posts (meta-select). I have it feeding out in a loop with 4 results. Let's say I want this loop to start with the meta value "2" and work ...
2
votes
0answers
48 views

List custom post type by custom tax term as page title

I have a page called "Developments" and I want to list all the Project posts by the custom tax Project Type using the page title as the term. This doesn't work: <?php $title_slug = ...
2
votes
2answers
54 views

Ordering terms before displaying posts

My question is close to other questions, but I dont' have enough reputation to comment. I'm working for a restaurant and I 'd like, for my menu page, to organise my posts "meal" under terms "...
2
votes
1answer
47 views

Hiding posts in a list from specified categories

Question How can I modify this code to not show posts from new categories that we just added. I searched other similar answers on this site [such as: Exclude category on blog list page ] but not ...
2
votes
1answer
1k views

Order post by year DESC and month ASC

I have a worpresss 4.0.12 website; i created a custom template category-$id.php in which I have to show post ordering them by Year DESC and by month ASC (or a custom field ASC), the result should be ...
2
votes
2answers
410 views

What is the difference between “manage_{$post_type}_posts_columns” and “manage_edit-{$post_type}_columns”?

What is the difference between manage_{$post_type}_posts_columns and manage_edit-{$post_type}_columns? Could somebody explain what is the difference between these two approaches?
2
votes
1answer
44 views

How do I query for a post by custom field?

I have a custom field called "song-id" and I'd like to lookup a post by a song-id value. Can someone give me the code snippet for it? (bonus: also looking for a code to use the permalink in the post ...
2
votes
0answers
446 views

Querying posts with meta value that begins with a certain pattern

I am trying to create a search filter using meta_query. The only problem I'm having now is that I can't compare with wildcards. I think that's how you word it? $keyword = 'sos'; $tlds = array('com','...
2
votes
0answers
2k views

query_posts with a custom post type, a meta_query and sorting by post date?

I've searched the archives and found questions similar to what I need, but haven't found exactly what I want. I've got a bunch of products that are sorted by a meta_key of country, and I'd like to be ...
1
vote
0answers
124 views

Blog post per page setting conflicting with custom WP_Query?

I am creating a theme, and have run into a problem with how a custom WP_Query seems to interact with the Blog pages show at most settings found under Settings -> Reading in the WordPress backend. I ...
1
vote
1answer
42 views

new WP_Query(), have_posts() return false in user_register hook

The $notifications->have_posts() return false, though I'm sure there are few posts of this custom type, in the database. add_action('user_register','jq_after_user_register_hook', 10, 1); function ...
1
vote
0answers
54 views

Gutenberg get core data - search

I am trying to query data in gutenberg like search in REST API. Following this documentation: https://developer.wordpress.org/block-editor/data/data-core/ I came up with this select: wp.data.select(...
1
vote
0answers
82 views

WP_Query adds “(wp_posts.ID = '0')” so no results are returned

I am doing a very simple WP_Query: $query = new WP_Query([ 'pagename' => 'some-post-slug', 'suppress_filters' => true // used by WPML to search in ANY language ]); However, the ...
1
vote
2answers
276 views

Bypass “supress_filters” in WP Query

Apparently, for some illogical reason, the developers decided that the only way to fetch posts in all languages, is to add supress_filters=true to the WP_Query (instead of having like say, a ...
1
vote
0answers
25 views

Get link which associated with a specific category and tag

We have 500+ post, 60+ tags, 3 categories. We want to give link on header part which have specific one category and one tag. For example: We have multiple post like: Blanket, Blender, Mixer, Wardrobe ...
1
vote
1answer
596 views

Get posts by category with pure SQL query

I have a meeting post type, whose titles automatically get set to a date of the form m/d/Y. I have the below query which gets all unique years from the post titles by selecting distinct values after ...
1
vote
0answers
46 views

ACF Query meta_values don't work with 'offset'

I am currently building a featured posts section and I'm using ACF to set which posts will be featured. As they're appear in another section, I want them to start in this query on the third post. ...
1
vote
1answer
45 views

how to make members list directory through wordpress post custom meta key.

I have created a website in which I am providing complete information about the organization. For this, I am using a Wordpress post. In which I am putting information of only one organization in a ...
1
vote
1answer
63 views

Get attachments from a post

I created a snippet to get all attachment from a post, included attachments from comments. <?php $post_attachments = get_posts( array ( 'post_type' => 'attachment', 'posts_per_page' =&...
1
vote
0answers
775 views

Polylang non-default language ignores tags in WP_Query

I have a mutual DB of custom posts that I'd like different languages to be able to access. If I loop through the post type only, all posts show in all languages, but once I add a tag to the query it ...
1
vote
1answer
23 views

How to edit this code to get the categories in achieve page?

I was building part of my category.php which will get posts from custom post type "product" and sure which will be included in the category what happen was it get ALL the posts from the custom post ...
1
vote
0answers
78 views

Add to query for the_content() on single page

I have a page template that, firstly, has a loop towards the top in order to display a list of links to testimonial custom posts (I'm using a plugin to re-order posts): <?php query_posts('...
1
vote
2answers
2k views

Cannot Update A Post, 404 Error

After months of leaving and deleting my WordPress site, I decided to try again. I downloaded the new version 4.7.3, installed and added a new post. So far so good. I then went back to edit the post ...
1
vote
0answers
121 views

Custom fields (wp_post_meta) vs Custom Table for large amount of data

This is already a common question but I didn't find an answer for my specific problem on my research, so here it is. I have a Custom Post Type that needs about 100 fields of data (these fields may be ...
1
vote
1answer
491 views

Filtering out child category posts from parent category archive not working

In this example cat 5 is the parent category, and 42 is a sub-category. I the main category 5 archive I don't want any posts from sub-category 42 displaying. Why isn't this working? function ...
1
vote
0answers
587 views

Frontend Post with JQuery AJAX to Php Issue

My problem is the following. I'm trying to make users publish custom post_type by frontend through a form like this: <form id="msform" enctype="multipart/form-data"> <fieldset id="...
1
vote
0answers
157 views

How to display an other custom post type in a different custom post type's archive?

Background: I need to display all posts of a custom post type called "recipes", that have a specific taxonomy "fish", right under the permalink "www.mysite.com/recipes/fish". What I have done: I ...
1
vote
0answers
46 views

How to retrieve an array of post IDs by a particular value stored in a custom meta's array

I have a custom post type 'projects' that has custom post meta 'members'. 'members' stores an array of another custom post type's IDs. I'd like to do loop through the 'projects' posts that have a ...
1
vote
0answers
733 views

Random ajax load only works with posts_per_page set to -1

I created a post loader shortcode, that uses AJAX to load posts. Even though I can set the order and order_by query parameters, the order_by should be random. From what I've seen on the web, ajax load ...
1
vote
0answers
33 views

Homepage's content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?

I have a custom field in my home page called "Featured posts". There are two fields: title and post. The post field returns post_object with post_type as posts. In my functions.php I have added the ...
1
vote
1answer
98 views

Query posts based on the meta key values of logged-in users?

I searched in WordPress Codes, and all of the online forums and tutorials about this but could not find any relevant solution. What I am trying to achieve is to create a query that lists posts for a ...
1
vote
0answers
81 views

How to get Related Custom Posts?

So i am having an issue where i try to get the latest posts but also the related one from Custom Post Format - Video. Didnt see anywhere this solution/tut, is it even possible, i guess it is. I just ...
1
vote
1answer
33 views

Display custom tags on pages that have a specific page parent

I would like to use Using the WP_Query or Query_Posts method. I'm currently using the query_post method. $terms_array = array(); if ($strurl == "somesite.com"){ $resparent = "18219"; //Page ID $...
1
vote
0answers
705 views

pre_get_post alter current post id

For some purpose, we want to apply a change to the Wordpress flow that affect's WooCommerce product page being displayed. When a product page is displayed (e.g. www.mysite.com/?product=my-product), ...
1
vote
0answers
130 views

How do I make query use exact post title

I am creating a custom search query in wordpress and the post title isn't matching. I want it to say the posttitle and the firstname have to be exact matches, or nothing should come up under the ...
1
vote
0answers
195 views

Wordpress tax_query not showing private posts

When querying posts with the following: $getClientsArgs = array( 'post_type' => 'client', 'showposts' => -1 ); query_posts($getClientsArgs); Private posts are displayed if the person ...
1
vote
1answer
96 views

How to display posts by vote count and if no value continue with latest posts with no votes?

Maybe someone can help me with this. I want to display posts by votes. Users can only vote up. So what I want is - the most voted posts by vote count on top and then latest posts with no votes. The ...
1
vote
1answer
69 views

How To Get Posts With A Specific Word

How to retrieve posts with a specific word in the loop. For example, I want to retrieve all posts with the title of the profile post (custom post type): http://www.wwefansnation.com/wrestler/dolph-...
1
vote
1answer
114 views

Query a WordPress page by its title (which has a parent page)

I have created a wordpress query which takes the entire content from 1 particular page using the its title So far i have the following: <?php query_posts('pagename=features'); if (have_posts()) : ...
1
vote
0answers
347 views

BBPress Search results in Wordpress search

I want to display in Wordpress search results page - 10 or less found results from BBPress (plugin) forums. I know that BBPress use custom post types (forum, topic, reply) but I don't know how to do ...
1
vote
1answer
275 views

Change order of posts

I made a post recently that did not explained myself right! Come again, but with better explanations. I need the "Select Option" change the order of query_posts. My current code is: <select> ...
1
vote
2answers
540 views

Getting movie and serial on actor page

I'm building a cinema site, I came with a problem, let me explain: Movies- are stored in Post's Actors- are stored in Post Type - persoane ( taxonomy= lista) Serials - are stored in Post Type - ...
1
vote
0answers
160 views

How to increase load time of an archive/search page (WP_Query)

I'm currently looking at why the archive and search pages take so long to use, and have found that the bulk of processing time is spent on the query_posts that is called before the template has even ...
1
vote
0answers
214 views

Listing all term items alphabetically / sorting loop

I have my own custom post type and it has its own taxonomy and terms. Whenever user visits http://example.com/mytaxonomy/myterm I want the page to display all items within this term alphabetically. ...
1
vote
0answers
31 views

Simple custom post query for all the posts or many of them not working

I am doing this query $args = array( 'posts_per_page' => '-1', 'post_type' => 'custom_post_type', 'post_status' => 'publish' ); query_posts( $args ); but it is not working I have around ...
1
vote
1answer
249 views

Query Page Content From Theme Options?

I'm trying to create a slider where you choose what pages are shown in the slider, using a theme options panel based on the https://github.com/vauvarin/options-framework-theme That lists the pages in ...
1
vote
1answer
232 views

posts_per_page option limits the number of Gallery items

I have noticed that if I have a query where posts_per_page are set to 4, any (image) gallery that belongs to one of those posts will too have only 4 items (although when I create the gallery from Add ...
1
vote
1answer
93 views

Sorting a query Field by date

I have my site, which at the moment is display university open-days, at the moment they are sorting by order of page title, when actually I would prefer they sorted in order of date, soonest first, ...
1
vote
1answer
128 views

Hook to return true when the_post() is used in a custom while loop

I fetch external data like this, but I also added the_post(); while($slice = mysql_fetch_assoc($result)){ the_post(); rest of my stuff } I need a hook to tell me if the_post() returns true, ...
1
vote
1answer
517 views

Sort by page information by Ascending Numbers

Basically I have a problem that I have details being pulled from advanced custom fields and I currently have them ordered by page title in ascending order. However, instead of ordering them Ascending ...

1
2 3 4 5