16
votes
Accepted
Is it possible to add custom fields to a WooCommerce attribute term?
Yes, it is possible. And there's an easy guide here.
Below is a working code you can add to the theme's main functions.php file:
// Adds a custom rule type.
add_filter( 'acf/location/rule_types', ...
14
votes
Accepted
How to add a custom field to quick edit
There are a few steps to create the custom quick edit box and custom column
create a custom meta key (assumed that you have 1 already)
add custom admin column title and data (assumed that you want to ...
11
votes
Visual Composer vs. Advanced Custom Fields
Tell your boss that Visual Composer is the cancer of WordPress. Tell your boss that you've separated content concerns from visual ones, and that you're not tied into an abhorrent shortcode nightmare ...
9
votes
Accepted
Add custom field to the archive page?
Using the Advanced Custom Fields plugin you can assign options pages to you custom posttype like this:
if( function_exists('acf_add_options_page') )
{
acf_add_options_page(array(
'...
8
votes
ACF - get fields from group
I'm surprised no one mentioned acf_get_fields('someGroupId') yet.
/**
* acf_get_fields
*
* Returns and array of fields for the given $parent.
*
* @date 30/09/13
* @since 5.0.0
*
* @param ...
8
votes
Accepted
How to get "Additional CSS Class" for ACF Gutenberg block
Note that I don't have ACF PRO 5.8 which comes with the Block features, but I hope this answer helps.
If you look at the example here, you can retrieve the additional/custom CSS classes using props....
8
votes
Accepted
ACF Repeater loops and resets - where is the reset_rows() documentation?
It's not in the documentation mainly because it's an internal function, they weren't expecting you to use or need it.
have_rows() checks to see whether there is a currently active loop- if not, it ...
7
votes
Accepted
Remove Category description textarea
/*remove term descriptions from post editor */
function wpse_hide_cat_descr() { ?>
<style type="text/css">
.term-description-wrap {
display: none;
}
</...
7
votes
Accepted
ACF add custom fields to categories and display
Check this page out from the ACF docs: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/
Specifically this section:
"Finding the term related to the current post"
<?...
7
votes
Accepted
ACF datepicker meta_query Compare Dates in m/d/Y g:i a - Not in Ymd Format
There should not be any need to do this.
Even if an ACF Field is using 'return_format' => 'm/d/Y g:i a',
The post_meta value is in YYYY-MM-DD 00:00:00 format.
$date_now = date('Y-m-d');
$args = [...
7
votes
Accepted
Using Advanced Custom Field (ACF) to insert meta description on each page
As mentioned in the comments, you are outside of the loop, so get_field will not know the ID. You can use the code below:
<?php
$meta_description = get_field('meta_description', ...
6
votes
Order and group posts by acf by month and year
When you query the posts with orderby argument as a event_date (it could be any field with date format) the posts are ordered by date, desc or asc. So the only thing you have to do afterwards is to ...
6
votes
functions.php inject inline css
The easiest way I've seen is to echo it where you need it:
function inline_css() {
echo "<style>html{background-color:#001337}</style>";
}
add_action( 'wp_head', 'inline_css', ...
6
votes
Using ACF to display data on all pages
As other users mention to create global options you need to have ACF Options Page add-on or ACF PRO. This will give you possibility to create nice options page and retrive your field in standard way:
...
6
votes
Accepted
Generate a excerpt from an ACF-wysiwyg-field
You can provide your own implementation of wp_trim_excerpt which is responsible for trimming and stripping HTML tags (it uses wp_strip_all_tags),
By copying the function source code and applying the ...
6
votes
Accepted
How to store ACF custom fields data in a custom table
It is possible to save ACF data in custom tables by using a separate paid plugin called ACF Custom Database Tables.
However, if your goal is just to keep the database as light as possible, meevly.com'...
6
votes
disable (read only) a field if within a custom post type name
Looks like I've found a way.
i've managed to find the field name in mysql :
function acf_read_only( $field ) {
$field['readonly'] = 1;
$field['disabled'] = true;
return $field;
}
add_filter('...
5
votes
Accepted
Replace post's "the_content" with ACF value
Instead of updating the post's content, you can filter it using the the_content filter.
add_filter( 'the_content', 'wpse241388_use_acf_field' );
function wpse241388_use_acf_field( $content ) {
...
5
votes
Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option
You're in luck. I was actually looking for an excuse to do this on one of my projects. I finally took the time to add this idea into one of my themes. :)
You can take this idea and run with it. It's ...
5
votes
Initialize JS with an ajax loaded ACF form
probably it's a bit too late, but it might either help you or others:
I just had a similar problem and while looking for the solution I found your question. By now I found a solution for me and it ...
5
votes
Accepted
What requirements for ACF custom fields key and name properties?
Reached out to ACF support, here is what I got:
I've done further experimenting and for Q1 I came up with a recursive function which prepends a prefix to all fields composed of field_ and a custom ...
5
votes
How to get current post ID in Contact Form 7 wpcf7_before_send_mail hook action
You can get the post ID from array variable $posted_data the form was send from
if ($submission) {
$posted_data = $submission->get_posted_data();
print_r($posted_data)
}
if you ...
5
votes
Accepted
Get full image array
The "full array" is constructed by Advanced Custom Fields from various sources. It's not a format that occurs natively in WordPress.
If you want to output an image tag for an image with all the ...
5
votes
Get full image array
If you're using Autoload/Composer you can use $image = \acf_get_attachment( $attachment_id ); to get an acf image array. If not I guess you can use require_once() to load your plugins/advanced-custom-...
5
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.
5
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 ...
4
votes
Filter next_post_link() and previous_post_link() by meta_key?
i had a pretty similar problem, needed to sort and exclude several posts from prev/next navigation. problem with @cfx's solution was: its not capable for ajax: the is_singular() function returns false,...
4
votes
Using OR conditions in meta_query for query_posts argument
According to the WordPress codex nested arrays can be used to construct complex queries. In your example your need something like this:
$args = array(
'taxonomy' => 'courses',
'term' => ...
4
votes
How to import CSV into Custom Post Type custom fields?
http://www.wpallimport.com/
There's a free version of this plugin that should do all the necessary work to import Custom Post Types from a CSV or Excel file.
The paid versions also allow you to ...
4
votes
Accepted
Conditionally loading JavaScript based on the Advanced Custom Fields in the post
ACF has finegrained filters for fields when they get loaded.
add_action( 'wp_enqueue_scripts', 'register_my_scripts', 5 );
function register_my_scripts() {
wp_register_script( 'my-script', 'path-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
advanced-custom-fields × 1514custom-post-types × 314
custom-field × 266
php × 186
wp-query × 155
plugins × 98
custom-taxonomy × 84
loop × 83
functions × 76
meta-query × 70
posts × 45
filters × 43
shortcode × 40
woocommerce-offtopic × 38
images × 37
customization × 34
post-meta × 34
taxonomy × 33
block-editor × 31
categories × 30
query × 29
array × 25
theme-development × 24
date × 24
search × 23