FAQ Database Discussion Community


PHP While and For Loop Grouping (using WP ACF)

php,wordpress,while-loop,advanced-custom-fields
Looping using a 'while' statment I get the following output: move_it clean_beauty on_our_radar move_it I want to output these where the fields (for $featured_type) are the same. Eg. I want to output as follows: move_it move_it clean_beauty on_our_radar Here is an example of the first example of what I currently...

add_image_size in advance custom field image - wordpress

php,wordpress,function,advanced-custom-fields,image-size
Ive made a custom image size in my functions.php file add_image_size('blog_image', 417,300, true); Then my code in the php file my image is showing <?php $image=get_field("post_image");?> style="background:url('<?php echo $image['url']['blog_image'];?>');" If I take out the ['blog_image'] my image appears on the page(without scaling the image) but when its added there is...

Can't use field name for have_rows() on WordPress ACF repeater fields

php,wordpress,wordpress-plugin,advanced-custom-fields
have_rows() is not returning any rows for the field name. I have a repeater field on an option page. Works: have_rows('field_554a52eedd894', 'option') Doesn't work: have_rows('advert_placements', 'option') The database entry looks like this: _options_advert_placements | field_554a52eedd894 and those values are on the WordPress page too. It seems to me that the...

Joining/summing custom fields in WordPress database query

mysql,wordpress,advanced-custom-fields
Despite Googling this for 2 hours and trying a variety of JOINS and UNIONS and ALIASES and whatnot, I still can't retrieve in one table the result of two subqueries in the wp_postmeta table from the WordPress database (I don't even care about wp_posts here, all the data I'm interested...

Wordpress Custom Post type archive display

wordpress,templates,custom-post-type,advanced-custom-fields
I have a custom post type named STORIES. Within that post type, I have categories, so each STORY is also assigned a category like this... Story 1 (assigned category RED) Story 2 (assigned category BLUE) Story 3 (assigned category GREEN) etc. I need to display a page which lists the...

WordPress/ACF: Sort Posts by multiple fields

wordpress,advanced-custom-fields
i have posts with two advanced custom fields "name" and "surname" and i need to query the post to have it in the right sequece. name / surnname / title like this: Doe, Joen, Title my query looks like this $args = array( 'numberposts' => -1, 'post_type' => array ('events'),...

How to display custom taxonomy fields into category loop?

php,wordpress,custom-fields,advanced-custom-fields
I have that code in my category.php which enables list subcategories <?php $categories = get_categories(array('child_of' => 7)); ?> <?php foreach ($categories as $child) { ?> //do stuff <?php } ?> For categories I've created custom text field with name = text. And now I want to show that custom field...

Wordpress: meta_query with custom fields ( posts get by sub-field ) (WP_QUERY)

wordpress,advanced-custom-fields
I create in WP a Custom Field with name='add_info' (type=Repeater) This field has a sub-field called comments (name=ai_comment, type=text) How i can get only posts with comments != NULL / EMPTY? $args = array( 'post_type' => 'cpt_articles', 'meta_query' => array( array( 'key' => 'add_info_%_ai_comment', 'value' => '""', 'compare' => '!='...

Loop custom field images

php,foreach,advanced-custom-fields
So I'm working with the Advanced Custom Fields plugin for Wordpress 4.1.1 and I created 4 custom fields: "topIMG", "leftIMG", "centerIMG", "rightIMG". I made them images so I can add more images to the post and place them a specific area on my page. So originally I wanted to display...

Query based on custom field

wordpress,wordpress-theming,advanced-custom-fields,wpdb
I have made custom fields using advanced custom field plugin. It has a field name school which includes choices such as arts,education,engineering. Now my problem is how can i query only those post who field is arts using wpdb. sincerely i don't know wpdb works. . Any help will be...

Use Taxonomy ACF to affect Custom Taxonomy post count

wordpress,advanced-custom-fields,acf,custom-taxonomy
Is there a way to use an "ACF Taxonomy Field" to affect "Custom Taxonomy" post count? Right now I am using ACF Taxonomy Field, but my Custom Taxonomies have 0 posts assigned. I want to use ACF to assign Custom Post to Custom Taxonomy: Instead of the default way: Is...

Show advanced custom field value in custom column (wp_list_table)

wordpress,function,custom-post-type,advanced-custom-fields
I made a custom post type named address and added values to it with the plugin advanced custom fields. I would like to display those values in a custom column in the wp-list-table. So I managed to add a column to the custom post type(address) called views. With the code...

WordPress custom field outside of loop

php,wordpress,advanced-custom-fields
I currently have a banner image on a site which is pulled in via the featured image. The code below that does this works: if ( has_post_thumbnail() ) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); $url = $thumb['0']; I would like to change this to use a custom field instead...

trying to retrive a post_type with custom fields and media query

wordpress,advanced-custom-fields,wp-query
Well, I've a created a post type with several custom fields (with ACF) and now I need to retrive the custom post_type by one of it's custom fields, that has an array as the meta_value, this is the code that I'm using to get the custom post_type $args = array(...

Wordpress & Advanced Custom Fields - Retrieving categories

php,wordpress,woocommerce,advanced-custom-fields
I seem to be having problems retrieving posts/attachments after connecting them to Woocommerce categories while using advanced custom fields. I've tried using the advanced example as detailed here and this is as close as I can get using that example: $images = get_posts(array( 'numberposts' => -1, 'post_type' => 'attachment', 'meta_query'...

Advanced Custom Fields adding an Image with a “Choice” field

advanced-custom-fields
I have an Image, that gives the photographer credit, that I would like to be able show depending on the Photograph. In ACF is there a way to set it up so that when I select a "Choice" field that the photo credit will show depending on the choice? And...

Wordpress custom post type - list only UPCOMING events - not ALL events

php,wordpress,advanced-custom-fields
I have a custom post type for events, with a field to display the event_date. At the moment, my code pulls in EVERY event. I need to to only pull in events that have NOT passed. Any advice on how I can only select posts that occur in the future?...

Wordpress Custom Post Type categroies

wordpress,custom-post-type,advanced-custom-fields
I have a custom post type called STORIES. When a user adds a new STORY, I need them to be able to assign a category (or multiple categories) to the post so I can sort them later by category. To do this, I only want specific categories I assign to...

Using an ACF image object for a custom taxonomy within an echo block loop

wordpress,advanced-custom-fields
I can't seem to pull a ACF image object for a custom taxonomy when used in this loop, which is made of echo blocks: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); $terms = get_terms( 'product_type' ); $image = get_field('product_type_tax_image'); $hero_image = $image['sizes']['medium']; foreach ( $terms...

Insert new line when updating field in ACF

wordpress,wordpress-plugin,advanced-custom-fields,acf
I'm using update_sub_field( array('subscribers_lists',$field_row,'subscribers'), $current_subscribers ); to update certain custom fields. Everything works as expected except when $current_subscribers has '\n'or <br> - it won't do a new line as I would expect. How would I force a new line when adding text to a field using ACF?...

WordPress: Display Posts by Year Set in Advanced Custom Fields

wordpress,advanced-custom-fields
I am trying to organize posts by year, based on what's been entered in the Advanced Custom Fields date picker (not the year published). I've been able to come very close to what I'm looking for using the year checker found on: http://alex.leonard.ie/2009/08/27/wordpress-grouping-posts-by-monthyear/ What I'm trying to accomplish is: 2015...

Advanced Custom Fields get sub field image

php,html,wordpress,advanced-custom-fields
I have a sub field in ACF, named 'imgcolumn_1'. This is set to be an image, and allows the user to add an image. Now, when in PHP, I am trying to retrieve the input the user adds. For example, I have another sub field in AFC called column_1, which...

Sort WP_Query by ACF Datepicker

php,wordpress,datepicker,unix-timestamp,advanced-custom-fields
I have a “Upcoming Events” page, and a “Past Events” page. Each event has a custom field called “event_date”. I want to create a loop that displays all of the events greater than today. I've taken a look through these articles, but couldn't get it to work: http://support.advancedcustomfields.com/forums/topic/how-do-i-filter-and-sort-event-posts-with-start-and-end-date/ https://wordpress.org/support/topic/plugin-advanced-custom-fields-sorting-by-date-picker wordpress...

Related Products ACF WordPress

php,html,wordpress,advanced-custom-fields
I am not using a WooCommerce plugin, just your normal site. I have a page, which I need to let the user select some 'related products'. Now, I am using ACF, and looking at using the Post_Object to allow the user to select the product. What this needs to do,...

How to Echo a custom field title only when filled?

php,wordpress,advanced-custom-fields
I have very basic php skills at the moment. I'm using a Wordpress plugin called Advanced Custom Fields. I have the basics down and have it working. It is echoing the results of the filled in field. What I want to do is have the title of the field only...

.toggle() applying to everything in ACF repeater

javascript,jquery,toggleclass,advanced-custom-fields
$( ".employee-big" ).click(function() { $( ".info" ).toggle( "slow" ); }); //these are repeaters so class gets repeated <div class="employee big"> <div class="info"></div> </div> so i have divs that when you click on it it shows the employee's info, these are advanced custom field repeaters in wordpress so the same class...

Images not visible in search results

php,wordpress,image,search,advanced-custom-fields
I have this custom search function to search trough custom meta keys in Wordpress. The function works well. However, all the images that I have added to my post using Advanced Custom Fields are now having their URL's changed to the attachment ID. This should not happen according to the...

Custom Fields, linking to a separate download page?

php,html,wordpress,advanced-custom-fields
Afternoon all, I have some Advanced Custom Fields set up, which allow the user to download files which are appropriate to a certain product. For example, if the product was 'Product 1', the files would be 'Product 1 size' etc. This works perfectly, using the following: <a href="<?php the_field('brochure'); ?>">Brochure</a>...

Advanced custom fields repeater / jcycle: unwanted random order

advanced-custom-fields,jcycle
on my portfolio i have some projects (for example http://mathieuserruys.be/art-cinema-offoff-voorjaar-2015/ ). These images are called via a ACF Repeater field, and they are put into a jcycle 2 gallery. this is the code i use: <div class="info" style='-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;' unselectable='on' onselectstart='return false;' onmousedown='return false;'><span id="prev">< prev</span><br>...