All Questions

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

Display featured image from one CPT within another CPT query

I have a WP_Query for a CPT of 'fixtures' that has a relationship with another CPT of 'fixtures_teams'. I want to pull in the featured image from the relative team in fixtures_teams CPT. $query = new ...
1
vote
1answer
13 views

Exclude admin from WP_Query Contributors

We are using this code to get a list of all contributors but we would like to exclude the admin from this list. Currently the admin and any role above the contributor role is being shown with this ...
0
votes
1answer
24 views

Exclude authors IDs from WP_Query

I am using this code, trying to exclude specific authors from WP_Query, however the author IDs in the array are not being excluded. Any ideas please? <?php $args = array( 'meta_query' => ...
0
votes
1answer
52 views

query posts in functions.php and update a field

I'm having problems querying posts in functions.php. This is mainly to update posts in the back-end, not to show a query on the front end. I'm trying to get all posts that use the status post format ...
0
votes
0answers
21 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-&...
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
1answer
46 views

Finding post ID dynamically on click

Goal: I'm making a portfolio website in Wordpress. It's the first time that I have setup a Wordpress page by myself (I have done on internship but those were template-ish). I have seen this website ...
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
22 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 ...
-1
votes
1answer
26 views

WP_Query and DES sort for Custom Taxonomy based upon a meta field?

Is it possible to filter events (WP Query) within a Custom Taxonomy archive by ‘Start Dates’? I create a Custom Post Type called “Events” and in that “Events” is a Start Date When I view Custom ...
0
votes
1answer
42 views

Loading two different AJAX requests on two different pages

I hav ebeen trying to call two separate AJAX requests, on separate pages, each pulling in their respective parts. Right now, it only pulls in ONE of the AJAX requests on both pages even with specific ...
0
votes
1answer
12 views

how to move a page from one drop down menu to another drop down menu

I have a page that is posted under one heading but I want to move the whole page to another drop down... for example from 'FOR SALE' drop down to 'RESULTS' drop down
0
votes
1answer
35 views

Getting the post terms 'wp_get_post_terms' per post when within the functions.php file

I have used a form with an Ajax action to pull post information through on submit. It works a charm. However, I have used categories to separate the work into categories. One of which is the brand. ...
1
vote
1answer
28 views

Function to check if author has posted within the last x days

Is is possible to check whether an author has posted in the last X days? I am currently using this function to determine whether he has posted at all. $args = array( 'post_type' => '...
0
votes
1answer
26 views

How to load a script code only in posts?

I want to load some JavaScript code only when it is posts, and not a home page or pagination! How can I do it with functions.php?
0
votes
0answers
19 views

How to upload 3 attachments to current post?

I have a form which updates a post but when updating I need to be able to also upload 3 posts: <div class="form-group"> <input class="form-control" type="file" tabindex="3" name="custom-...
0
votes
1answer
613 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
403 views

Shortcode returns escaped HTML tags

To put things in context, I'm using Gantry on WordPress, which is bundled with Timber and Twig. I have this code, basic, make-your-text-bold shortcode // Add Shortcode function bold_text_shortcode( $...
2
votes
1answer
147 views

Best practice custom function, where to echo the variables?

I have a custom function to query some posts. I was wondering if it is okay to echo variables within the loop of the function, since normally I would echo a variable at the end of the function. If so, ...
1
vote
1answer
137 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
0answers
22 views

get video poster image by video id

Using wp_query i got list of videos. All videos have their own poster images. How to get them? To make sure video exists i tried function wp_get_attachment_url and i got video url and its correct. ...
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
0answers
23 views

subtracting the current post form then whole loop, which is generating all CPT titles

<select class="title_select minimal"> <?php $loop = new WP_Query( array( 'post_type' => 'plugin', 'posts_per_page' => -1 ) ); ?> <?php ...
-1
votes
1answer
25 views

How to write a query-function as a query-shortcode?

I ask this question as a follow-up to this one. I have this query-function in functions.php but AAMOF I don't want to change functions.php at all (besides for CPTs). I'd like to print the same data ...
1
vote
2answers
66 views

How to delete taxonomy term when a wordpress user is removed?

i need to Delete wp_terms -> name field when a user is delete . my requirement is admin needs to assign posts to specific users, that is admin need to add a post to user1 ,but user2 should not see ...
0
votes
1answer
46 views

Post not populating for custom post type based on category selection

This question is actually an extension of this question. For default post type posts are populated based on category selection from the drop down, but when I change the settings for the Custom post ...
0
votes
1answer
347 views

Global page ID variable empty error

I am creating theme and I have a need to create global variables within theme functions.php file. Currently I am doing it like this: /** * Setup globals */ global $nb_id, $nb_page; $nb_id = ...
0
votes
0answers
769 views

Custom Post type Ajax search results

I'm trying to return search results without reloading the page, using ajax. I followed some tutorials, but i can't find a way to return the results, it loads, stops, but doesn't return anything. If ...
4
votes
1answer
2k views

Wordpress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given

I am running Wordpress 4.9.5 and occasionally see the following error in my logs. E_WARNING: trim() expects parameter 1 to be string, array given The stack trace looks like this, so it's not coming ...
1
vote
1answer
196 views

How to get user_id from wordpress database inside ajax function?

I have an ajax function which switches the view type of the user's posts from list mode to grid mode via ajax but the problem is that when the wp query is being called it can't get the id of the user'...
0
votes
3answers
338 views

Get current user id

I need to print the user's id into this array but it doesn't seem to be working. I have tried all sorts of things from $user->ID to $user_id to no avail. I am trying to get the value from my functions....
0
votes
1answer
222 views

Multiple meta_key ordering with pre_get_posts

I'm trying to order products by multiple meta keys, so that the most selled products appear first and the out of stock products lastly. I managed to make the out of stock products show in the end, ...
1
vote
1answer
66 views

Exclude category for main query and custom

As you can see, on the second line here, I am effecting the main query only. This would have no effect on custom queries elsewhere on the site. How do you apply it to custom queries too? function ...
0
votes
1answer
581 views

Custom query vars filters problem with pagination

I have multiple custom query vars to filter products with the pre_get_posts hook and the add_query_arg function. All works fine except the pagination, when i navigate to the page number 5 (for ...
2
votes
1answer
46 views

Finding post content that begins with a specific character

If I want to find all posts where the very first character(s) of the post text / content (ie not the title) are "<" or "<a" How would I do so? I tried these solutions: https://...
1
vote
1answer
458 views

Remove query string specific key value

I'm adding multiple values of the same key as a query string with add_query_arg function to filter products. The problem is that i want to remove only the value of the link clicked instead of the ...
1
vote
1answer
55 views

How to call WordPress function other files

Hi All i am in word Press I have successfully integrated WordPress membership plugin and all data of users is saved in database. Different users have different levels. My major task is to disable ...
2
votes
1answer
277 views

Finding all results from database within 500 miles of the given latitude and longitude [closed]

I am stuck into this problem where the main requirement is to find all results from the database which are within 500 miles of the given latitude and longitude. I have stored the lati and longi into ...
0
votes
1answer
336 views

how to access query string in wordpress?

There are several ways I have seen this question worded, so I tried to make mine generic. Let's say I go to this page: example.com/page/?utm_source=test&s=test&page=12 get_query_var('...
1
vote
1answer
36 views

Get users that likes the post

I have an ajax like posts system when a user like a post the system added a post meta to the post and it's named (post_liked_users). Example of post_likes_users meta value: a:1:{s:6:"user-1";i:1;} ...
0
votes
2answers
526 views

Loop increase number

$args = array( 'post_type' => 'events', 'order' => 'ASC', ); $wp_query = new WP_Query($args); ?> <script type="application/ld+json"> { "@context":"http://schema.org", "@...
1
vote
0answers
29 views

wordpress search word, “hello world” ===> ‘hello+world’ ===> ‘hello’, ‘world’

I need a Function Code to improve the wordpress search engine For example, if the user searched: Hello world First, the results of Hello + World are searched and the next results: Hello and world ...
0
votes
1answer
29 views

Security for data obtained from the database

I am getting information from the database to show it to the user, example: $data = (get_option('config')) ? get_option('config') : false; I need to display this data when loading the webpage, ...
0
votes
2answers
56 views

WP_Query & shortcode : Return 3 articles from a category WordPress

I would like to display the last 3 articles of category 'camping-camping' with a shortcode but the function does not seem valid, an idea ? function derniers_articles_camping() { // the query $...
2
votes
1answer
41 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 ...
0
votes
0answers
266 views

Get post Number with local loop and template

Following on from my previous question: (Calling a custom excerpt function in a local loop ), I am not understanding why echo $wp_query->current_post; in template.php is returning -1 for every post ...
1
vote
1answer
988 views

Calling a custom excerpt function in a local loop

I have a function that sets the excerpt length of the first post differently than the posts that follow, but I cannot get it to work. Any input would be appreciated. functions.php (the function) ...
0
votes
0answers
56 views

Save query in function for custom gallery

At this moment I am developing a custom gallery which has a constant changing layout. Because of this, it's hard to write a loop file, cause depending on how many items the style keeps changing, ...
1
vote
0answers
65 views

How to do set post permalinks using 6 digit random unique function?

I need the following: e.g. www.e.g.com/hello-world to www.e.g.com/9xY52a of course function check 9xY52a inside the databese posts.
0
votes
1answer
78 views

Dynamically Override Fancy Title - Part II

I followed instruction by @pat-j and @cjbj in this answer: Dynamically Override Fancy Title and I got the result of override title. Now I need to dynamically change this title. I have written this ...