Tag Info

New answers tagged

0

ACF needs the term slug as a second parameter to be passed in order to retrieve the value. It's explained in detailed here. http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ get_field('field_name', term_slug');


0

Seems I need to find the term id before displaying the field $terms = get_the_terms( get_the_ID(), 'album_category'); http://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/


1

I've just solved this issue thanks to the Avanced Wordpress group in Facebook (https://www.facebook.com/groups/advancedwp/). It was actually a mistake I had made: I had a query before the custom fields and it had to be reset. This is the working snippet: <?php // WP_Query arguments $args = array ( 'post_type' => 'post', ...


0

You need to generate the shortcode within the loop, and then execute it afterwards: if ( have_rows( 'homepage_slider' ) ) { $shortcode = '[ux_slider timer="4500" arrows="true" bullets="true" auto_slide="true" nav_color="light"]'; while ( have_rows('homepage_slider') ) { the_row(); $shortcode .= '[ux_banner bg=" ' . get_sub_field( ...


0

The following code works for WordPress >= 3.5 (source). I couldn't get it to work the ACF way. No need to use 'meta_query' this way. Just replace 'meta_query' with the following two lines to offer_args and and it should work. 'meta_key' => 'home_offer', 'meta_compare' => 'EXISTS', // or 'NOT EXISTS' if no offer.


1

Sorted it out myself. The problem was, server was very slow to process the import. The process was happening behind the scene but server actually went down. When server was up, I could see all the content on the other site.


1

The users doesn't have permalinks nor titles. They have author links and display names. Changed the code: <?php while ( have_posts() ) : the_post(); ?> <h2>Resturants</h2> <?php $resturants = get_users(array( // Changed from get_posts ...


0

After more sleuthing, found an appropriate solution: <?php // Solution for sorting by ACF custom-field for tracks categories // http://support.advancedcustomfields.com/forums/topic/sorting-categories-list-by-custom-field/ $categories = get_categories('taxonomy=tracks'); $sorted_cats = array(); foreach($categories as $cat){ ...


0

There's no need to "pass" the order to your third foreach - just loop over $issue_archive again instead of $terms.


1

If you want to exclude ALL pages that doese't have 'collaborator' set as author, then you want to exclude all other pages in the site and include all pages of that author minus, maybe, some hand picked pages of that author, then I think you can use this: add_filter('acf/fields/relationship/query/name=products', 'exclude_id', 10, 3); function exclude_id ( ...


0

Thanks Phil Hoyt, this was exactly what I was looking for. But, alas, I couldn't get it to work with my setup. What does work is the following: <?php // Solution for sorting by ACF custom-field for tracks categories // http://support.advancedcustomfields.com/forums/topic/sorting-categories-list-by-custom-field/ $categories = ...


1

Found a solution that works: add_filter('acf/fields/relationship/query/name=products', 'exclude_id', 10, 3); function exclude_id ( $args, $field, $post ) { $args['post__not_in'] = array( $post, 9, 10, 11 ); return $args; } Added in functions. This will exclude the pages with id 9, 10 and 11.


1

When I had developed a theme, and I was trying to automate the import process by tweaking wordpress-importer plugin. I had faced the same issue. When importing server processes numerous DB operations at same time, that's why it's not able to respond and it results in 500 Internal server error. Try 1 : To fix the issue, you have to import one by one. ...


0

Please check your .htacess files there might be some issues in it. You may even try to rename it.Hope it helps I was stuck with similar issues little time ago.


1

Anything to do with using the Google Places API is going to be off-topic here, but the best place to start would be the developer docs. However, how you interact with the API data within WordPress is certainly on-topic. I would suggest a wrapper function that caches the results periodically: /** * Get places data for a post. * * @param int|WP_Post ...


0

I ended up using $wpdb for my custom tables and went with wp_query for my custom posts with ACF fields $q = new WP_Query(array( 'post_type' => 'coupon', 'post__in' => $cids )); $coupons = array(); while($q->have_posts()) : $q->the_post(); $p = get_post(); $f = get_fields(); $m = ...


1

You need to loop for the results and call get_fields() again. So after your code add smt like: foreach( $locations as $l ) { //grab post id $pid = $l['ACF_Relationship_Field'][0]->ID; // grab fields $fields = get_fields($pid); // add them back. As ACF_Relationship_Field is an object I will add it next // to it, but you can do whatever ...


0

In register_taxonomy you can pass page as the associated post type and it will become an option on the edit screen register_taxonomy( 'custom_tax', 'page', $args ); http://codex.wordpress.org/Function_Reference/register_taxonomy


0

There's no need for the custom meta SQL filter - the beauty of storing dates in the format Ymd is that you can treat them numerically, and MySQL will still be able to find events in a given "range" and sort them ascending/descending. I've done this recently on another site using ACF for start/end date: if ( ! empty( $_GET['_y'] ) ) $year = absint( ...


0

Figured it out. I had to re-read the codex a lot to figure out that when you pass an array to update_post_meta it is serialized. By using maybe_unserialize() on the return value I was able to to get access to the values. Hope this helps some future searcher!


0

You can use this code for getting number of posts in a taxonomy: $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'your-taxonomy-name', 'field' => 'slug', 'terms' => 'some-slug', ) ) ); $query = new ...


0

You need a meta query. There's also documentation on ACF for querying dates. <?php $event = new WP_Query( array( 'post_type' => 'gacr-event', 'posts_per_page' => 5, 'orderby' => 'meta_value_num', 'order' => 'DESC', 'meta_query' => array( array( ...


2

Try using the count variable to increment the loop. <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> <?php if(get_field('faq_general_ht')): ?> <?php $count=0; ?> <?php while(has_sub_field('faq_general_ht')): ?> <div class="panel panel-default"> ...


0

Use this- while($loop->have_posts()) : $loop->the_post(); ?> <p><img src="<?php echo get_field('attorney_photo'); ?>" /></p> <p><?php echo get_field('attorney_name'); ?></p> <p><?php echo get_field('attorney_areas_of_practice'); ?></p> <?php if( ...


2

is_plugin_active() only available inside the admin area. You need to include the core plugin.php file in front end to use this function. From WordPress documentation NOTE: defined in wp-admin/includes/plugin.php, so this is only available from within the admin pages, and any references to this function must be hooked to admin_init or a later action. ...


1

Try to check class_exists: <?php if( class_exists('acf') ) { echo "hi"; } ?>



Top 50 recent answers are included