4
votes
True/False ACF field returning null by default even if default value is true
You will need to update every existing post otherwise, you will get NULL every time even if you set the default value to TRUE.
You can bulk edit/update altogether.
3
votes
True/False ACF field returning null by default even if default value is true
As Harit Panchal mentioned.
Creating a new ACF field, true/false in this case, and setting a default value for it, wont automatically set this value for every existing post, page, term, etc, it's ...
2
votes
Accepted
How to detect if an ACF custom-field is really in use?
Most sensible here is probably just a custom query
global $wpdb;
$sql_find_meta =
"SELECT post_id
FROM database_name_here.wp_postmeta
WHERE meta_key = 'my_special_value'
AND meta_value > '';&...
2
votes
Display posts from specific slug of the custom taxonomy in Wordpress
I would recommend becoming intimately familiar with the WP_Query parameters:
https://developer.wordpress.org/reference/classes/wp_query/
In your particular case; dealing with taxonomies:
https://...
1
vote
Display custom post type attached media file sizes
From your array, you should get the Media ID of the videos. If you have the media ID, it will be as listed below:
// Let's say you have the media ID
$meta = filesize( get_attached_file( $attachment_id ...
1
vote
Accepted
Best performance for use Custom Field in WP
Neither will be faster because the root of the performance problem is the WP table design, not the plugin. The post meta table is optimised for finding values when you already know the post ID/keys, ...
1
vote
Custom Sort Order for Custom Post Type Taxonomy
Use usort with a custom callback, like this:
function compare_term_order_numbers( \WP_Term $a, \WP_Term $b ) : int {
$order_number_a = get_field( 'order_number', $a );
$order_number_b = ...
1
vote
Accepted
Post object GUID adding http:/
You should not be using the GUID as a link. If you want to get the URL for a WordPress post object you should use get_the_permalink():
href="' . esc_url( get_the_permalink( $package_link ) ) . '&...
1
vote
True/False ACF field returning null by default even if default value is true
The answers so far explain how to fix this but not why it happens. The issue exists because when you created the existing items the default was null. This means that the existing items have a value in ...
1
vote
Accepted
How to get all specific fields from one ACF Group?
U can use get_fields() which return all fields from current page.
Additionally you can filter array checking which key matches.
Example:
$questions = get_fields();
$questions_array = array_filter($...
1
vote
How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post?
You should probably check out pre_post_update.
Use pre_post_update to check for a post update within your custom post type Container of Things. Check for your conditions. Then, get the connected ...
1
vote
Accepted
Upload non-featured image to image field
You should read up on the wp_insert_attachment function. You can check it out here https://developer.wordpress.org/reference/functions/wp_insert_attachment/. It does not automatically set the image as ...
1
vote
Function wp_enqueue_style was called incorrectly
Wordpress uses a system of so-called "hooks", which are functions that are run at specific points within the process of building the webpage for the browser.
The system runs like this:
A ...
1
vote
get the title of a relationship field
you don't need a function...
$my_query = get_posts(array(
'post_type' => 'post_type_name',
'meta_query' => array(
array(
'key' => 'relationship_field_name',
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
advanced-custom-fields × 1473custom-post-types × 301
custom-field × 259
php × 176
wp-query × 147
plugins × 98
loop × 86
custom-taxonomy × 81
functions × 74
meta-query × 65
posts × 43
filters × 42
shortcode × 40
woocommerce-offtopic × 37
images × 37
post-meta × 35
customization × 34
taxonomy × 33
categories × 31
query × 28
block-editor × 26
search × 25
array × 25
terms × 23
date × 23