All Questions

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

how to display wordpress post which is published in past 5/10/20/30/60 minutes & 1/5/12/24 hours slabe?

I want the page to show a list of published news in a particular time frame. Please take a look example :- Here is my code which i am using : <?php ...
0
votes
2answers
13 views

Add code to the header of posts by particular author

I want to add CSS code to the header of all the posts by a particular author. I tried the following solution: function hide_author_box() { if (is_author('ritesh')) { ?> <style> ....
0
votes
0answers
12 views

Date object in the query to show posts from the following month

I'm building a booking for events, each event is divided into taxonomies, this is the query that regulates my custom post type, to display all the posts that are under the "aperitivi" taxonomy. $...
0
votes
0answers
22 views

Sort posts numerically by converted date format

Updated for clarity: I need to convert the post date format from Y-m-d to mdY and sort by mdY numerically, not by the actual timestamp. My goal is to order the posts by month first, then day, then ...
0
votes
0answers
20 views

match and update acf fields with array values

i created array from gravity forms entries that has information about students payment. this array contains only the values i need about payments. $arr: [6047] => Array ( [0] ...
0
votes
0answers
8 views

in WordPress Loop update_user_ meta with Current Month and Year as Meta_Ley

I am making a page for my wordpress authors to see there stats. For the same, i first loop through all author ids, then i loop through all of there posts, and sum the post views meta key for all. I ...
0
votes
1answer
24 views

Hide posts if user is added to it WP_query

I have this list of posts in wordpress. I've made a favorite function that when you mark something as favorite it gets added to the front of the line. The issue here is I run this 2 place. One top ...
1
vote
1answer
20 views

Get Current User Id Inside a Loop Returns 0 For a Shortcode

I am having function, which has a loop for all the posts of given author. I use get_current_user_id() but that does not seem to work while inside a loop, or may be the shortcode troubles it. My ...
0
votes
1answer
15 views

Search for single post by 2 tags

i have "Tag1" and "Tag2" i want to find most recent post with both tags.So far i have tried this, i know im close, but it is listing all posts containing either tag. $args = array( 'relation' ...
0
votes
0answers
12 views

Paged WP_Query is quitting on page 3

I am having this problem where every time I run this, it stops on page 3. There are about 15000 products that are published. So there should be at least 30 pages. I narrowed it down to the $loop = ...
0
votes
1answer
46 views

How can I group posts by months and years?

I have posts under a custom post type which I like to display in a page grouped by Year and Month. In the page template that I create, I managed to separate them by month, but still without grouping ...
0
votes
1answer
30 views

Getting info about selected posts using one WP_Query

I'm currently working on displaying recent posts in 'masonry grid'. Because of multiple issues I came out with the idea of displaying pre-defined rows of that grid (due to designed layout). First I ...
0
votes
1answer
45 views

Undefined $post in wp_query

I have a custom post type called resources. On it's post template, I have a widget which will display posts which have the same tags, i.e. If I'm on an article post, the widget will show other ...
0
votes
0answers
9 views

Grouping Upcoming Events and Past Events custom ACF meta keys

I'm having an issue grouping upcoming events and past events with their own specific headers. A Visual example of this would be: --- Upcoming events ---- event - - event - - event - - event - etc... ...
0
votes
1answer
13 views

Get Child of Child Pages in custom Menu

Got this bit of code which runs which gets the Page ID and displays all the children under it. Which is good. Part two of this is getting it to pull in the child of children items. So currently ...
0
votes
2answers
16 views

List all ACF field values across every post on one page

I used an ACF repeater field for data sheets/instruction manual download links of products in woocommerce. There's 50 products and each has 1 to 4 download links on their product page. I've been ...
0
votes
0answers
109 views

Wordpress search query, how to modify the sql

I have a problem with the query search, which means I would only look for posts with post_status = published. The problem is that after adding my conditions, wordpress writes an "OR wp_terms.name LIKE%...
0
votes
0answers
28 views

Modify post image in full size

I have a website where the client attached many “full size” images to posts, most of them in 5000px width, is it possible to run something for resizing those images to large? Instead of going through ...
0
votes
0answers
23 views

Wp-query output correct, but the loop shows one less item (only sometimes)

My site is making a strange bug, the code below works 99% of the times but every now and then it return only 2 items in the loop, even that the query results have more products // get the cats this ...
0
votes
0answers
11 views

sql query page listing with option selected

I want to separate a page page from the sql query. for example current page and last page with option selected. my listing page code <ul class="list-group"> <h2 class="h3">...
0
votes
0answers
31 views

Require_once failed to open stream WordPress

I've been trying to create a small plugin to do some basic tasks on my website. I created the plugin which was initially working fine, I made no changes and for some reason it no longer works. Here ...
0
votes
1answer
24 views

WP_Query based on another query on the page

I have a query that checks for a custom field set on that page and then creates a carousel to loop them with a background image. What I then want to do, is query a post type that uses a custom ...
0
votes
2answers
34 views

Tell wordpress to show a single page instead of an archive page

my wordpress site urls like this: https://example.com/?pid=a125a5&lang=en and query of my archive page like this: <?php $the_slug = get_query_var('pid'); if ($the_slug){ if ( $post = ...
0
votes
1answer
26 views

Exclude posts with specific metadata from search?

I have created this searchfunction that looks like this: function search_data_fetch() { $search_query = new WP_Query( array( 'posts_per_page' => -1, 's' => esc_attr( $_POST['keyword'] ), '...
0
votes
0answers
22 views

pagination problem with select option

I have a select option menu and a wp_query. when a user choose an option, it shows related posts. everything is great but pagination. pagination is working good, it shows pages and when you click page ...
0
votes
0answers
29 views

Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields

I'm trying to fix an issue that requires multiple array queries inside a loop. I'm no PHP whiz, but I got one part to work. I can't get the other part to show correctly. I'm using a collapse repeater ...
0
votes
1answer
35 views

How to display sticky post always at the top (before regular post) in wordpress?

I am working on a wordpress code as shown below in which the modified post displays at the top. $temp_args = [ 'post_type' => array('current-channel', 'post', 'current-episodes'), '...
1
vote
1answer
23 views

Random order of WP_Query results with highest meta value

I need to random of cars with highest price. My code: $argsLoop = array( 'post_type' => 'cars', 'posts_per_page' => 12, 'paged' => 1, 'meta_key' => '...
1
vote
1answer
13 views

Add more button if more 8 items

I want to add a "more" button if more than 8 elements, I tried it <div class="under-menu__countries"> <span class="under-menu__title">Countries</span> ...
0
votes
1answer
56 views

Custom route and query

I am trying to use a custom WordPress route and function, but I am getting a route and function not found error. Below is my code but I am not sure where it is breaking: add_action('rest_api_init', ...
0
votes
1answer
21 views

Search result based on URL

Currently I am using bellow function to display search results from Custom Post Type. add_filter( 'pre_get_posts', 'tgm_io_cpt_search' ); function tgm_io_cpt_search( $query ) { if ( $query->...
1
vote
2answers
732 views

How to create a WP_Query to search the Title or Tag?

I have created a search using WP_Query, it seems like this query is looking for the queried term in title AND tags. Is there a way to have this search the title OR tags? $s = $request['s']; $tags = ...
1
vote
1answer
56 views

How to store post ID's in cookie or session to display the same posts later

I run a wp_query that fetches 4 posts from db with rand() and displays them in a grid to visitors. What I need is to display the exact same posts the query fetched the first time, a second time to ...
0
votes
0answers
27 views

User switching through frontend without going to wordpress admin panel

I have two user roles for example, 1.staff 2.Instructor I need to switch to staff when I am in instructor when clicking a button in frontend. As same as I need switch back option also to switch back ...
0
votes
1answer
12 views

Pulling Individual Posts from WP_Query

I'm trying to run a WP_Query and then put each of the 3 posts pulled from that query into a differently formatted div in my template. However, when the code below runs, I end up getting the first post ...
0
votes
0answers
28 views

More pages avaible than max number in pagiantion

I found out that my pagination display for example max 2 pages but I can freely go to (max) 5, changing the number in the url address. It' avaible until I change the value to 6 or more, then I got 404....
0
votes
0answers
27 views

Same content on Wordpress - Pagination with custom query

I am making own template for WP and I have problem with pagination. The content is always the same on every page. I read many pages about this problem and I implement the solution, but it doesn't ...
2
votes
0answers
55 views

Can an array be used as a meta_query value?

I'm trying to query a custom post type (courses) by grade using WP_Query and Advanced Custom Fields (ACF). Grades (checkboxes) are organized by term (groups). Four grades per term, four terms per ...
1
vote
2answers
269 views

AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely

I have multiple wp_query's on the same page. Each one of those queries has an AJAX "read more" button at the bottom. The problem I'm finding is that I can only get one to work at a time. Whichever ...
1
vote
1answer
30 views

Custom page archive query by url var calling page twice on one of my custom queries?

This is such an odd issue. I will try and break it down as simply as I can. I am creating my own custom page query which works like an archive using url variables to customise the query results. ...
0
votes
1answer
657 views

WP_Query To Display Product Of Brand On Taxonomy Page

I am trying to print all products of a brand on a taxonomy page. I find the wp_querry but i cant print the current brand name of the brand to show all products in this page. What to put on terms ...
1
vote
1answer
84 views

WordPress custom slug (endpoint) and compare all links

I work on the one i18n function. It will work with subdir. For example: eg.com/hello-world/en For this I'm support EP_ALL for the WP custom endpoints. function lang_add_endpoints(){ ...
1
vote
1answer
142 views

Use wp_get_recent_posts with search term

I have a function that uses wp_get_recent_posts() I need to use this same function on my search page but am having problems adding the search parameter to the $args array. Does anyone know if this ...
0
votes
1answer
131 views

Meta query not showing result properly

In wordpress posts I have custom meta fields (ship from, margin price). I want to filter post by these meta fields. Ship from fields contains multiple value (Example: A product can be ship from china ...
0
votes
2answers
278 views

Combine multiple queries, array_unique returns nothing

I'm combining multiple queries for a loop using the following method: function order_by_date( $a, $b ) { return strcmp( $b->post_date, $a->post_date ); } // get the posts for the first ...
0
votes
1answer
61 views

How to add 2 posts under another post? Formatting should be intact

The goal is to print 2 articles under an article IF the article is 200 words or less. I've had some help over at WordPress, but the code a couple of helpful people provided I can't integrate into a ...
0
votes
1answer
82 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'...
1
vote
1answer
659 views

WP_Query use for a filter with multiple Taxonomies and Terms

So, what I'm trying to do, is to make an ajax filter, this is the portion of the filter code that builds the $args based on the data that came from the filter form, and afterwards (not in this code) ...
0
votes
1answer
40 views

Getting posts to exclude from array

I have an array, where keys are the post ID's and values are post titles. $options = []; $args = array( 'posts_per_page' => -1, 'fields' => '', ); $posts = get_posts( $args ...
0
votes
3answers
104 views

Get all posts as an array ID => Name

I need to query all of my posts as an array in example: 'options' => [ 'Post ID' => __('Post Name'), 'Post ID' => __('Post Name'), ], How can i do it? tried this but it gives me ...