get-posts
how to load random related posts with specific custom fields?
I want to load 3 posts that have the same custom field value as the current post.
for example:
The current post has 3 custom fields:
color: black
background: red
lastname: doe
Now I want to load three posts with these custom fields:
first post: color:black
second post: background:red
third post: lastname:doe
these are my codes:
Is it possible to query posts with tax queries after multisite switch_to_blog() function?
On my newly installed multisite with 1 installed plugin ACF. And all code below is not being run though any filter or action and on the front end.
How I can change the condition or compare operator for WP_Query in pre_get_posts
So here is my problem
I want to show Posts if have same category if not have post then show post of same tag. And to do that I am using “pre_get_posts” action. and setting query like following.
Recent posts on homepage: different thumbnail based on logged in status and post category
This works well on archive.php, but not working on the homepage. For some reason, the first statement doesn’t get applied: if a post is in Members category and user is not logged in, it’s supposed to show a default placeholder image, but instead it’s still showing the actual post thumbnail.
Form checkbox value going to dynamic URL
Well, I have a Database made mostly with ‘Advanced Custom Fields’ in a page on my site that is supposed to get all the STORES (custom post type) of a city and show them to me, and by changing dynamically the URL I could made it get a genre, type, etc “www.urltoshow.com/ville/Paris?genre=Man”…
var_dump and print_r cause white screen
My template is very simple:
Ordering posts in get_posts
I am having a custom block which uses the following code to fetch a list of comma separated posts.
get_posts() SQL Injection
I’m working on a custom search page and I usually use wpdb->prepare when crafting custom queries. But this time I went with get_posts to create the below query. But I’m wondering if I have to worry about SQL Injection with it. Should I? Or does get_posts() have that security built in?
php loop error for count posts in category
I have multiple categories on my wordpress page and each of the categories has 1 to n subcategories. If a subcategory contains only 1 single post I would love to display an excerpt of this post, otherwise I’ll display a description of the category.