Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

Wordpress Post Query Using Custom native MySQL like St_Distance_Sphere

Is there a way to query posts for "the loop". But include some filter on the results based on a mySQL Function like St_Distance_Sphere? Or convert a wpdb->query into a form similar to &...
Enjabain's user avatar
  • 101
1 vote
1 answer
38 views

Why does 'get_the_ID' work outside of the loop?

on WordPress Developer Resources website's page related to get_the_ID() function it says: Retrieves the ID of the current item in the WordPress Loop But I can use it outside of the loop and it works ...
Daniel's user avatar
  • 193
0 votes
1 answer
1k views

get_the_ID() retrieves same ID on Gutenberg's Query Loop

I'm using Gutenberg editor and I want to add a shortcode (using XYZ PHP Code) that uses the post id to retrieve certain ACF value. I'm editing the home page where the last blog posts are shown, but I ...
Alvaro's user avatar
  • 141
0 votes
1 answer
40 views

How do I exclude the current post from the upcoming post query

Summary: I have a page template with 3 queries. Current Exhibition Upcoming Exhibition Past Exhibition The dates are custom fields. The problem I'm having is, how do I dynamically exclude the ...
Chris Brennan's user avatar
0 votes
1 answer
133 views

How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]

I am using ACF Pro to make a relationship between two custom post types. One CPT is a thing and the other is a Container of Things. I need to solve the issue of things within a container of things ...
Jordan W.'s user avatar
0 votes
1 answer
134 views

Conditional operator OR not working with custom fields

OR operator is not working for both conditions, only check first value if true then code executed and if first is false then not check 2nd condition and return else output. I also try with LIKE ...
Puneet's user avatar
  • 47
0 votes
1 answer
113 views

Include current post into loop

I have a related posts loop ( in every single post page ) based on post title. source : https://wpza.net/get-related-posts-based-on-the-posts-content-in-wordpress/ But I also need to include current ...
Teymur Abbasov's user avatar
0 votes
1 answer
154 views

Why does my WP_Query pagination on a custom page.php only loads the homepage?

What I am looking to do: Setup WP_Query pagination in a custom php template file with a custom WP_Query query (It's not originally mine, I'm just fixing it). The file loops through posts (category &...
Lisa's user avatar
  • 13
0 votes
1 answer
119 views

Get posts that do not have the same tags as current

I'm trying to get all posts in a custom plugin loop that DO NOT share the same tag as the current one. I'm trying: $events = tribe_get_events([ 'start_date' => 'now', 'eventDisplay' =&...
Eli Nathan's user avatar
0 votes
1 answer
190 views

Get a Post Loop based on Logged in User information into a Shortcode

I have a follower button on users profiles where users can follow other users. I have a page template that shows all posts by users the currently logged in user follows. I would like to create a ...
RobH's user avatar
  • 7
0 votes
1 answer
2k views

Pagination not working on custom query on a page

I have a custom query on a page (it is not an archive page), it works just fine, but I want pagination and it is not working at all... <?php $paged = (get_query_var('...
Cheo Molina's user avatar
0 votes
1 answer
17 views

Loop through posts of only 2 statuses

Setting up a visibility condition for a widget - i need it to apply to the posts in a certain term but only those of "pending" and "publish" status. this essentially hides the &...
DCEXC's user avatar
  • 7
0 votes
0 answers
83 views

Duplice post with standard WP loop - fixed by using query_posts() instead

I have an index.php file on a website designated as the blog page. I have an archive.php file which handles all the subsequent category pages. I ran into an issue on the archive page, where for one of ...
Hewe's user avatar
  • 75
0 votes
0 answers
22 views

Is there anyway I can call the year once?

Hi everyone I hope you have a great day, I was wondering if is there anyway I can call the year once?. I really don't know if its possible to call the date once cause mine keeps on repeating calling ...
jricc russel's user avatar
1 vote
1 answer
2k views

Slow WP_query due to nested wp_query. Need Suggestions

I'm facing an issue of slow queries. As I'm not that familiar with the WP_query, I managed to solve my problem with nested wp_query. https://it.zoetalentsolutions.com/technology-provider/aws/ in the ...
Danish Mohammed's user avatar
1 vote
0 answers
901 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 ...
p01ntbr34k's user avatar
0 votes
0 answers
186 views

How do I stop the same post showing multiple times in a archive?

For some reason the archives for my custom taxonomy is showing each post 3 times and I can't seem to figure out why. Here is the page: https://portfolioadviserlink.com/topics/esg/ $...
Ibrarr Khan's user avatar
0 votes
1 answer
2k views

Group posts in a category based on tags in custom taxonomy

I had my built-in posts set up with categories and tags. I created a template that would display posts of the category that matched the page slug. then it would group them by the Tags. for example, ...
Steve's user avatar
  • 313
4 votes
1 answer
1k views

How to exclude latest x posts from a paginated query?

I have a WordPress loop, that is part of an AJAX call. Every time a button is clicked, this function is called, runs the below loop and outputs the next 6 posts. There are already five posts shown by ...
ralphjsmit's user avatar
1 vote
1 answer
67 views

Two loops, one AJAX loop, exclude posts in first loop from second loop, loops are in different files

I have two loops that display posts: the 'default' loop (in home.php), which displays five posts. At the bottom of the page I have a button, that invokes an AJAX call, which calls a second loop and ...
ralphjsmit's user avatar
-1 votes
1 answer
127 views

Pagination in category.php not functioning

Original Url: https://www.something.com/category/ftm-atf/ When I add pagination in, the following url is generated which results in a 404: Paginated Url: https://www.something.com/category/ftm-atf/...
Gene Ellis's user avatar
0 votes
1 answer
1k views

Should I reset $wp_query?

I am not totally new on WordPress but the query thing is a bit confusing to me. I searched the web and read a lot of articles, but I couldn't find what I needed. Maybe it could help a lot of people ...
LovinQuaQua's user avatar
0 votes
0 answers
84 views

how to add 4 post in one carousel slide

I want to display 8 posts in twoeach carousel slides, that mean 4 post in each slide. i'm using a loop to display post but the problem is, it is showing one post in one slide and hence displaying 8 ...
karuna's user avatar
  • 1
0 votes
1 answer
250 views

How to show post views shortcode data for each post on Posts List Page?

Example: [shortcode id=""]. I just want to how to dynamically fetch each post ID on Posts Lists page over archive page or normal posts page inside the shortcode placed in excerpt. Currently I'm using ...
parmanand's user avatar
  • 101
0 votes
0 answers
127 views

Custom query for custom post type not getting correct post ID

I have written a custom query here: <?php $the_query = new WP_Query( array('post_type' => 'video', 'posts_per_page' => 10, 'post_status' => 'publish') ); ?> <?php if ( $the_query-&...
WordCent's user avatar
  • 1,877
0 votes
0 answers
29 views

Problem with my loops

I am French. Sorry if i make mistakes. I have two problems. The first, I have a page that shows all paying activities sort by date. The 'posts_per_page' does not work When I put 10, it shows 8 ...
Lol72's user avatar
  • 1
1 vote
1 answer
298 views

Duplicated posts on category page

So, I have archive.php file with this part of code <div class="column is-full is-three-quarters p-small"> <?php while ( have_posts() ) : the_post(); get_template_part(...
MMPL1's user avatar
  • 267
0 votes
1 answer
1k views

How to get post ID in a Page?

I'm trying to list all of my posts in a page(with post's content). Everything is showing correctly but the audio player which uses post id to get the URL of an attachment in the post is not showing. I'...
Shikhar Mishra's user avatar
1 vote
3 answers
1k views

Separate First Post Loop

I'm trying to use the <?php rewind_posts(); ?> feature to use two loops on my homepage template. Does anyone know how to stop the first loop after the latest post? Here is my Code: <?php ...
user1313336's user avatar
0 votes
0 answers
76 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 ...
Ozgur Polat's user avatar
1 vote
2 answers
303 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 ...
AB Siddik's user avatar
  • 113
0 votes
2 answers
2k 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. ...
user2125467's user avatar
0 votes
0 answers
59 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 ...
Rameen's user avatar
  • 11
1 vote
1 answer
113 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 ...
EmilyH's user avatar
  • 73
0 votes
1 answer
392 views

Assign a class to first element in category in loop

I am trying to do the following: 1) assign col-lg-4 class to the first element in the loop, when there are 3 or more posts within the given category. 2) assign col-lg-8 class to the first element in ...
Olek Tomkowski's user avatar
0 votes
0 answers
70 views

How to order posts, that have already been filtered by custom taxonomy, by their category names?

My question is not a duplicate, because in my case posts have already been sorted by custom taxonomy term. The question is how to order posts by their category name AFTER they have been sorted by ...
Azamat's user avatar
  • 361
0 votes
2 answers
2k views

How to add <ul> in WP_Query to every 3 posts displayed? [duplicate]

I want to display every 3 products in a <ul> Example of how HTML should look: <ul> <li>product looping 1</li> <li>product looping 2</li> <li>...
Rhian Molinari's user avatar
0 votes
2 answers
71 views

Get the amount of posts on a current page

I have loop and I want to get the amount of posts on a current page. So I try: <?php $post_number = $wp_query->post_count; ?> <?php echo($post_number) ; ?> <?php while ( have_posts()...
name name2's user avatar
1 vote
2 answers
829 views

Five posts from a category in footer

I am trying to show 5 posts from a category in my home footer. I have placed this code <?php query_posts( 'category_name=entertainment&posts_per_page=5' ); ?> right in my home.php file ...
Tarrmie de Man's user avatar
0 votes
1 answer
2k views

Display Posts on Custom Page

I have a custom page template created for my homepage. I have this set to the Static Homepage under the Reading settings. I want to be able to show the last three news posts from my Blog page which is ...
Beau Beau's user avatar
2 votes
1 answer
997 views

Separate Posts and Custom Post Type in Custom Taxonomy archive template

I have created both a Custom Post Type (Match) and Custom Taxonomy (Team), and have made the Team taxonomy available to normal posts (news for that team) and the Match custom post type. However, on ...
Ronan's user avatar
  • 123
3 votes
1 answer
749 views

Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]

The rewind_posts function is meant to be used when the loop is going to be called more than once in a page with the same query. If I call the same loop a second time in the page the result is the ...
Alvaro's user avatar
  • 2,593
4 votes
1 answer
6k views

Get the number of posts from the current page results

I am trying to get the current number of posts that will be present in a page. $wp_query->found_posts will give me the total number of posts in the loop. get_query_var( 'posts_per_page' ) will ...
Alvaro's user avatar
  • 2,593
0 votes
0 answers
341 views

Use special template for the first post in the loop

I want to use a special template for the first post in a loop. So I tried this: <?php while ( have_posts() ) : the_post(); if( $wp_query->current_post == 0 && !is_paged() ...
Pravayest Pravayest's user avatar
1 vote
2 answers
2k views

How to query 'posts_per_page' to display a different blog posts index template?

Trying to create a 'switching' blog template using home.php, controlled by 'Blog posts per page' setting in the admin area. If set to '1', it will show the single post template. Anything higher and it ...
user avatar
0 votes
3 answers
93 views

Posts are not looping through correctly

I am trying to make the page have 3 posts in each row, and then after 3 columns (12 posts) show the ajax load more button. Right now only one post is showing up. I don't know how to make it correctly ...
user6738171's user avatar
0 votes
1 answer
174 views

Using functions.php to include code that's processed inline

I have a somewhat complicated WordPress template that keeps getting more complicated as the client wants it to work this way under one condition and another way under another condition, and so on and ...
Nora McDougall-Collins's user avatar
1 vote
1 answer
399 views

popular post weekly and monthly

i want to display popular posts for 1 week ago and 1 month ago.these are codes that i used but these don't work correctly for 1 week ago <ul> <?php $week = date('W'); $year = ...
m.javad Koushki's user avatar
-1 votes
1 answer
4k views

Render a loop in Timber (twig for Wordpress)

I would like to render this loop in Timber. $query = get_posts(array('post_type' => 'lexique','posts_per_page' => -1)); $by_letter = array(); while( $query->have_posts() ) { $query->...
Xroad's user avatar
  • 101
0 votes
1 answer
371 views

Loop through custom taxanomy in post and display custom fields from posts

I will try to elaborate the title. I want to make a post, within this post I want to loop through all posts from a custom taxanomy and extract custom fields. How is this done in the most efficient ...
2by's user avatar
  • 115