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.

Filter by
Sorted by
Tagged with
1
vote
1answer
57 views

How to query custom post types posts filtered by multiple custom taxonomies through a form selection

I'm trying to create a sort of selection menu, in order to select custom posts by different custom taxonomies. I did the selection part, but I can't get to output my post and I can't understand where ...
2
votes
1answer
2k views

Quickest way to get last or oldest post date - WP Query

I know how to get the last or oldest post data using following code $posts = get_posts(array( 'post_type' => 'post', 'order_by' => 'publish_date', 'order' => 'ASC' )); And then I will ...
1
vote
1answer
438 views

Reset Popular post query?

I am using the following code to display most read articles. I think it takes the lifetime of the articles as it displays very old articles first. How can I reset it - weekly? in my function.php ...
2
votes
1answer
271 views

How to get previous 10 days post from a specific date - WP Query

I want to know how to get previous 10 days post from a specific date, as I know that it can be done from current date as below $args = array( 'post_type' => 'post', 'date_query' => ...
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
575 views

How to display certain category in the loop from WordPress default post type?

I want to display a certain category from WordPress post type, but it is not showing... Here is my quote. it displays all posts instead of "wedding venue" category post. <?php $args = array( ...
1
vote
1answer
113 views

How can I pick a single post from the latest 3?

I'm looking to display a single featured post from my latest 3 posts at random. I've managed to get it up and running picking any post at random just fine, but I want to filter it down to only the ...
0
votes
0answers
38 views

Wordpress For Loop Prints Unwanted Extra Paragraph Element

I have the following code to list my authors in my sidebar except for the admin account. It works very well in function. However, it prints an extra paragraph element that includes two ancor tags with ...
0
votes
1answer
151 views

Frontend form with multiple posts

I've been researching frontend post-editing/creating forms, but I can't seem to find anything about having multiple forms on the same page. Please excuse my shaky understanding of POST methods. Here ...
1
vote
1answer
152 views

Prevent <title> change with new query_posts()

I have to display 12 items of my custom post type on the front page of my theme. However, when I do this, the page title (<title>...</title>) changes to Custom Post Type archive - Page ...
0
votes
1answer
30 views

How to put orderby on a custom field in query_posts

I have the following query in my query_posts and want to add order by to this. Order by will be on another custom field and sorted by desc order. Here is my existing query. //show all active posts ...
2
votes
1answer
350 views

How to display recent posts added in several custom post types

So I have several custom post types on my site and would like to have a place on my home page that will show the most recent 6 posts from 3 different custom post types. I have looked at the setup on ...
0
votes
0answers
199 views

how to display active, upcoming and past event with featured listing with pagination

I have a code that work fine for Active Events Page, Upcoming Event Page & Past Event Page with a event_start_date later than today. What I want is? A : To show Active, Upcoming, Past event post ...
1
vote
1answer
2k views

posts_per_page => 1 shows 2 posts

I am trying to add a button to take the viewer to a random post. Below's the code I am using:- <?php query_posts(array('orderby' => 'rand', 'posts_per_page' => 1)); if (have_posts()) ...
0
votes
1answer
13 views

Assign a day of the week to post, e.g: Assign Monday to post and have it only appear when the day is Monday

What I really want to do is have a system where I can write Monday in a custom field on the post then it only shows up on the website on that day of the week. I want to do this for all days of the ...
0
votes
0answers
329 views

Group Custom Posts Types in a Relation field of ACF

We have a different custom post types such as 'Paper', 'Publications', 'Events', 'Media'. When creating a 'Paper' post type, I use a 'Relationship' field of ACF to link to different posts from ...
1
vote
2answers
115 views

show a post from a specific post format

I want to show 4 posts from a WordPress post type where 1 will show the post from the link format and the other 3 will be shown from another format. So in this case, how to use the query or what ...
0
votes
1answer
61 views

How to search CPTs in draft using get_page_by_title()

I'm aware that get_page_by_title() is not an option when you want to look for posts (or CPTs in my case) that are not published (i.e. in draft). Some of the solutions that I've found are based on SQL ...
2
votes
1answer
62 views

How add a custom posttype name using ACF field to a query post array

I'm loading custom post type to different pages by changing cat id and sometimes post type name query_posts(array( 'post_type' => 'posttype_name','posts_per_page'=>-1, 'tax_query' => array( ...
8
votes
1answer
7k views

WP Query where title begins with a specific letter

I want to search for posts with WP_Query() and select only posts that begin with a specific letter. I found a bunch of old posts with filters that were pre-4.4, but since 4.4 there is a title search ...
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' =&...
0
votes
1answer
65 views

Get the most recently modified post date of most recently modified post

I have Googled this, but there are always answers to get the modified date of a single post, which I know how to do. What I'd like to do is get and display the most recent modified date of the most ...
1
vote
1answer
794 views

WP_Query “OR”: Find posts by ID, Name or Post Title?

Hey there for some reason I have a function which has to find posts by either ID, name or post title. It looks like this: /** * @param $name_or_id: Name or ID of the post to find * @param $posttype:...
0
votes
1answer
336 views

Posts query according to meta box date

I'm struggling to get a working solution with wp_query for Event management, Currently post order by event start date & time work well. Now I want some custom settings. Have two meta boxes ...
0
votes
1answer
737 views

How to get only one category of custom post type?

I get all post successfully of CPT which are Order by meta_key value Date. Code is below $today = date("Y/m/j"); query_posts(array( 'post_type' => 'event', 'posts_per_page' => 10, 'meta_key' =&...
0
votes
2answers
48 views

Get posts by user role in a Multisite

Currently, I can only get the post by user roles on specific sites. What I need is to have a query that will get the post from user role on other site. Example Users: Site A - user(admin site a, ...
0
votes
2answers
1k views

WP_Query: Show 10 posts in date order, first three random

I have looked online and found different pieces of code together but unable to find a solution that holds up. Basically i need to display 10 posts in total, but the first three need to be random. ...
1
vote
2answers
65 views

show first 3 thumbnails of posts in different sizes [closed]

i want to make a little Header with the 3 recent thumbnails in different sizes and start my loop with the 4th recent posts, can someone give me a function for that please? please no widgets i want to ...
0
votes
2answers
2k views

Use WP pagination functions on a custom page template

I have a custom page template, I'm using a standard WPQuery to fetch the posts from the default posts custom post type. I'm looping through all the posts however now I have more posts than I allow in ...
0
votes
1answer
121 views

WordPress website loads more posts than expected

On the homepage of a WordPress website the latest posts are visible. In the dashboard it's set to display 10 posts on the home page. However, it loads 133 posts. Switching to the default theme didn't ...
0
votes
0answers
45 views

Can I show some specific post rather than latest post?

I have created a custom post for slider of my theme using owl carousel.As by default, it always shows latest post first in the slider.If I want to show some specific post,what can I do. Although the ...
0
votes
1answer
33 views

Getting Custom Posts with Custom Taxonomy

I am trying to get the custom posts "contact" with the custom taxonomy "abteilung" for this post type. Everything i am trying is not working. Now i am stuck with the following. The problem is, that ...
2
votes
1answer
1k views

How to show only one post for each categories of taxonomy of custom post that contains a specific custom field

I have a custom post called 'account' and custom taxonomy called 'bank'; What I'm trying to do is to show with wp_query post a list of post that should have a specific custom fields named 'tax'. ...
0
votes
1answer
624 views

Show 5 posts and than 3 posts offset with pagination

I am trying to get the first 5 posts displayed with different styles, and then the next 3 with different styles. They need to have working pagination as well. On my readings setting I have set the ...
0
votes
1answer
213 views

Wordpress query reverse order

$args = array('post_type' => 'etlap', 'posts_per_page' => 5, 'post__in' => $ids, 'post_status' => 'any', 'orderby' => 'post__in'); I want to make the orderby status reversed. How is it ...
0
votes
1answer
106 views

allow user to edit posts made by others users based on the user role

I group users by custom user roles so each user groups can view and edit each others CPT . the problem i face now is when i give the user role capabilities related to edit and delete others posts, the ...
1
vote
2answers
210 views

Store sticky post's ids in a transient

I'm developing a theme that has a featured posts section before the main loop of posts. Cool and fresh, right?:) All sticky posts with a featured image in place must be displayed in that section and ...
1
vote
1answer
3k views

How to find out what “Blog pages show at most” is set to [duplicate]

Under Settings > Reading, there is a field called Blog pages show at most __ posts. Since all of my queries are based off of the main query, I need to find out what's stored in that field. How would ...
0
votes
1answer
72 views

How to show post title in content editor in backend?

Is this possible? I am trying to use a pre-defined template for my contents. To do that, I use something like this: add_filter( 'default_content', 'custom_editor_content' ); function ...
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 ...
0
votes
1answer
50 views

Make blog page show 10 on first page, 9 on every other page

I'm trying to do something very similar to this question: Have different number of posts on first page The only difference is I need 10 posts on the first page of the blog and 9 posts on every other ...
0
votes
1answer
2k views

Meta_query 'compare' => 'LIKE' not working?

I have meta field with key"app_i_have" and values in my mysql db like: a:3:{i:0;s:14:"mobile studio";i:1;s:12:"own studio";i:2;s:9:"makeup artist";} Now i want to query posts through the pre_get_posts ...
0
votes
2answers
35 views

Custom posts listing widget always returns 1 extra result

I've built my own custom 'recent posts' widget to display some more content than the default core WP recent posts widget does. I'm struggling with controlling my list of entries. Currently, the widget ...
0
votes
1answer
21 views

Render content of multiple pages and their descendants

I'd like to expose a route to my site, animals.example.com/book, that shows all content of pages and descendants specified in a query parameter. For example, if my page structure is intro pets ...
0
votes
1answer
75 views

Query the title of the page to show posts with matching category in the loop

In the archive page for a custom post type I have this query: $the_query = new WP_Query( array( 'category_name' => 'Bordeaux' ) ); Then in the loop I have: if ($the_query->have_posts() ); Et ...
0
votes
1answer
196 views

wp_query args with relation

I'm trying to write a wp_query that will filter out posts with a certain tag only if they are also 1 month old. All posts older then a month without the tag are displayed and any post less then a ...
0
votes
1answer
54 views

Query to list all galleries under a parent post?

I have many child galleries organized by their parent galleries (multiple parent galleries with several child galleries under). I would like to create a shortcode that is able to query all the child ...
0
votes
1answer
26 views

Remove post from latest posts after a month only with certain tag

I was wondering if there is a way to modify the wordpress loop to check posts with a certain tag and if they have that tag and are 1 month old not display them in the latest posts on the homepage? ...
0
votes
1answer
243 views

WP_Query to get posts in a specific tag or has post_format

I want to get the posts for two different taxonomies. I want to list posts only if those posts either have tag longform or the post_format is type link. I have tried the below code, but it's not ...
0
votes
3answers
71 views

Get $post Object from another page

This is a rather simple question, so I'll keep it short. Update1: In this context {page-structure} means just that: page1/page1-1/page1-1-1/{...}. Update2: For further clarification, I want to do ...

1 2
3
4 5
24