All Questions
393 questions
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 &...
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 ...
0
votes
1
answer
42
views
How to get total posts count for each date?
function test_dashboard_content() {
$args = array( 'posts_per_page' => -1, 'post_type' => array( 'post', 'page' ),
'post_status' => 'publish', 'date_query' => array( 'after' => '...
0
votes
0
answers
20
views
WordPress current post functions inside loop doesn't work anymore, are they incompatible with php 8.0?
I recently update php from 7.4 to 8.0 , since many functions doesn't work anymore !
I don't know if it's related but I have tried many solutions and none of them works.
Using (get_...) , the_title, ...
0
votes
1
answer
50
views
Global $post value outside the loop
On a category archive page, in a filter called from a block outside a loop, I noticed that the get_post function with a null first parameter returns the first loop's post.
Is it supposed to return ...
0
votes
2
answers
32
views
List of published post dates only outputting one date
I have the following, which works, but only returns a single post date:
function test() {
$args = array( 'posts_per_page' => -1, 'post_type' => 'post', 'post_status' => 'publish' );
$...
0
votes
0
answers
27
views
Default post showing more than intended
I have a ajax set up where I am loading post categories via ajax request on click of a button.
I have a default query that is loaded for when the ajax filter is not set so a default state.
It should ...
-1
votes
1
answer
147
views
button onclick with get_post_permalink
I developed a custom post type.
On my archive page for each post there is a <button>.
The problem is that I can't put the link to the post in question.
My button is in my loop.
<button type=&...
0
votes
1
answer
111
views
Is it possible to use the_post 2 times in one loop
I have a page on which I want to display all my posts from my custom post type, which I am able to do in a single column. However, I want to display the posts in 2 columns.
For this, I will need two ...
1
vote
2
answers
264
views
How to use a conditional statement in a post loop but not count towards the "posts_per_page" if false
I have a WP_Query which has the "posts_per_page" parameter set to 12. I am then using a while loop to iterate over all of the posts and an IF statement to check whether a condition is true ...
0
votes
1
answer
258
views
Count the number of matching post names in foreach loop
I have a simple foreach loop that outputs an ordered list from a CPT 'post_subscribers' and an associated meta key called 'project'.
$theposts = get_posts( array(
'post_type' => '...
1
vote
0
answers
326
views
WordPress Ajax load doesn't work
Hello I have set up custom Ajax load more without plugins, but it’s only showing 3 posts on home page, and when clicking on button to load more it’s not loading anything. As I am a beginner I am ...
1
vote
1
answer
410
views
Wp Query : Order by distance lat,lon
I'm new to this forum, sorry in advance :)
I have a problem with my display of my posts
Let me explain ^^
I want to perform an orderby => '$distance' and display the posts accordingly.
$lat2 and $...
0
votes
1
answer
90
views
ACF to select posts not displaying on blog page
I am trying to implement a repeater / post object so I can select posts that I want to displaying on the sidebar. I am using this code:
<?php while ( have_rows('top_posts_repeater')) : the_row(); /...
0
votes
1
answer
231
views
Add custom text automatically on each post
Suppose I have a post and it's the first paragraph is:
"This a Pen. The color is red."
I want to add a custom text like "2022" after "Pen" on first sentence, at the end ...
0
votes
1
answer
522
views
ACF flexible content block not showing on live site (works locally)
I've made a flexible content section in ACF for a specific category that allows the user to post text and different image galleries onto their post. This all works perfectly whilst I'm on my ...
0
votes
1
answer
329
views
Getting blog pagination to work on page set as front page
From what I understand, if the page is the front page (using front-page.php) you would use get_query_var('page') and for other pages you would use get_query_var('paged'). I have a condition for this ...
0
votes
1
answer
26
views
Want to change the post every three days with in specific category
I have one post on homepage of a specific category. I want it to change after three days and pick the next post of the same category. Is it possible?
0
votes
1
answer
1k
views
View post with specific category id and name which I selected in the backend (drop-down option)
I'm trying to get the category ID from Kirki Function and then pass the ID into a loop to get View all posts from that specific category id with name.
I write this code at the backend:
Kirki::...
0
votes
1
answer
198
views
Extracting relevant tags associated with that particular single post only
$tags = get_tags(array(
'hide_empty' => false
));
echo '<ul>';
foreach ($tags as $tag) {
echo '<li>' . $tag->name . '</li>';
}
echo '</ul>';
The ...
0
votes
3
answers
83
views
Display articles with a different template in the home page | Solved |
I am creating a theme for my site. I would like to display the last 5 articles on the home page but with a different display for the first articles.
So I created this code that I try to tweak but ...
0
votes
1
answer
32
views
When and how will php code in a user made Wordpress page be executed?
What I have understood about what's happening when a web page in a Wordpress built web site is loaded is that Wordpress determines which post (page) and which template for that page to load. It then ...
0
votes
1
answer
47
views
Permalink Short code showing unnecessary link text inside the loop
Recently I need Help regarding this permalink shortcode
function my_permalink(){
ob_start();
the_permalink();
return ob_get_flush();}
add_shortcode('my_permalink','my_permalink');
for this, I get a ...
0
votes
1
answer
98
views
Make loop inside slider divisible [closed]
I'm trying to divide a posts loop in order to show 4 posts per each slide inside a slider.
The code below works good, but since the number of posts in the Wordpress panel is dynamic and varies, it ...
0
votes
2
answers
163
views
Wordpress query undefined offset in loop
I created a query with arguments see blow.
On the page I see an error in a loop
Notice undefined offset 1
Notice undefined offset 2
Notice undefined offset 3 and so on...
$args = array (
'...
1
vote
1
answer
50
views
Exclude category from
I am trying to exclude a category from <?php the_category(', ') ?> inside my loop. I came across the following code on CSS tricks that says would solve the problem. You add this to the functions:...
1
vote
0
answers
80
views
Wordpress Loop - Next 3 Posts
Hoping someone here can lend me some advice or point me in the right direction.
I have a working Wordpress php function where I can get the next 2 posts in the loop of the current post within a post ...
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 ...
0
votes
1
answer
35
views
First x post with another template then the others
I want to output the 5 latest posts. But the template of the first 2 must be different than the other 3 posts. So I've created two queries.
The first one shows the 2 posts:
<?php
$loop = new ...
0
votes
1
answer
557
views
How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
PHP and Html Code
<?php
//get your custom posts ids as an array
$...
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 ...
0
votes
1
answer
1k
views
Why this function doesn't works without the_post?
I'm a beginner wordpress developer, getting a lot confused in the_post(); function, apparently it doesn't perform anything that can be visualized, but if I do not invoke this function my code breaks ...
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 ...
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 ...
1
vote
1
answer
27
views
problems with loading posts in a table-row
I am trying to modify a code in a webpage.
Currently the page has a table, table-row, table-cell structure where thumbnails which represents posts of a specific category and associated data are loaded ...
0
votes
1
answer
299
views
Current post categories and subcatecories outside of the loop
What I would like to achieve is getting the posts categories and subcategories (without needing subcategories to be related to this post) (when viewing the post) in a list outside of the loop, ...
2
votes
0
answers
488
views
Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
I am trying to embed a custom WP_Query inside a shortcode I have activated on one of my pages (created in Elementor). I have a Custom Post Type called 'inspector-profiles', and for some reason when I ...
0
votes
0
answers
27
views
Multiple post in One Loop in wordpress
I’m converting HTML website to wordpress dynamic and having trouble getting duplicate posts. Code is following kindly please guide me in this regard m new with wordpress and PHP.
<div class="...
0
votes
0
answers
34
views
Display specific posts based on an ID of another post
I'm trying to display specific posts based on an ID of a post. I got it working with 2 posts and I will get it working for the 10 posts that I need it for, but it's going to be a lot of code and I ...
0
votes
0
answers
195
views
SEARCH QUERIES - REVERSE OUTPUT
When I perform a search on the WP admin side for my custom post query I am returned with the most relevant queries first. Great
However, performing the same search on the front end of the site and I ...
0
votes
1
answer
240
views
Import Instagram post to Wordpress blog post
I'm looking for a way how I can import an Instagram post to a Wordpress post.
So to make it clear: I'm NOT looking for a Instagram Feed plugin. I need to import an Instagram post to a Wordpress blog ...
0
votes
1
answer
691
views
Numbered Pagination Showing The Same Posts After Altering WP_Query
I think the title sums the problem up, but I'll explain more with the code below.
As you can see, I'm trying to start the loop from the second latest post for some theme reasons which forced me to ...
0
votes
1
answer
38
views
"read more" redirects to the wrong page
I would appreciate it if someone can help me out. I am having issues with my blog posts. I had someone customize by site but they made a mistake with the blog posts. I am no longer working with them.
...
0
votes
0
answers
23
views
Diffrent layout for posts [duplicate]
I have two rows to display posts
in first row i have two posts image + content , image + content
And in second row the post layout change means content + image , content + image
can you solve this my ...
0
votes
1
answer
1k
views
Display current post position in Elementor Posts widget
I'm using Elementor 2.6.8 + Elementor Pro 2.6.2
I'm designing an Archive template to display a list of Custom Post Types filtered by custom taxonomy terms.
I'm using Posts Widget from Elementor Pro ...
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 ...
0
votes
0
answers
26
views
Need to display a Jan 1st post as the site's front page on Jan 1st, and Jan 2nd post as front page on Jan 2nd etc
slightly unusual client request. I'm using Divi and I have a nice Divi layout created for a video and text post which is ready to go. The client wants to create 365 posts (one for each day of the year ...
0
votes
1
answer
35
views
Wordpress posts loop pagination - first page return 125 posts instead of 10 and the rest return 10
I'm trying to show 10 posts per page with pagination on WordPress and the first page return 125 posts instead of 10 and the rest of the pages return 10 posts as requested, please assist :)
$paged = (...
0
votes
1
answer
444
views
How to use alternate post layout at key points in post loop?
How can I intervene in my post loop output to show 3 posts in alternate mark-up, and then resume?
I have a post loop that calls my post card template fragment, card-pair_top.php, to display like this....
0
votes
3
answers
125
views
'posts_per_page' => '10' does not show any post
everybody,
I have created a custom_post_type;
function create_post_type_veranstaltungen()
{
register_post_type('veranstaltungen', array(
'label' => __('Veranstaltungen'),
'public' ...