advanced-custom-fields

Pagination with Custom Post Type and Taxonomies return 404

二次信任 提交于 2019-12-12 04:34:43
问题 I've been trying to fix this issue since last week but I can't get it done. The problem itself sounds quite simple, my pagination on WordPress works just fine when it's not dealing with taxonomies, for example: www.example.com/post_type/2 but if I try to use a taxonomy, I can't go past page 1 (www.example.com/taxonomy/term/2). Custom Post Type = noticias and Taxonomy = assunto, so I don't think the name is a conflicting factor here. $custom_query_args['paged'] = get_query_var( 'paged' ) ? get

Get ACF field key programmatically by field name

心不动则不痛 提交于 2019-12-12 04:19:25
问题 I need to get the field key by field name in WordPress in the Advanced custom fields plugin (ACF). The field is assigned to a post. I am in the loop of the post and I want to get the field key programmatically USING field name. The reason for this is because i'm creating a form where the field name 'options' will stay the same but will have different options in a select. I am looping over a custom post type and expecting the field 'options' to be assigned to the post (each post will have

How to get posts filtered by custom field that is post object type?

时光怂恿深爱的人放手 提交于 2019-12-12 02:49:30
问题 I want to get posts of an specific post type where those have custom field with type of post type. I have post type named "tour", and tour post type has custom field named "country" that its type is Post Object. The query for get all tours that their country is "Turkey": $located_tours = get_posts(array( 'numberposts' => -1, 'post_type' => 'tour', 'meta_query' => array( 'key' => 'country', 'title' => 'Turkey', 'compare' => 'LIKE' ) )); But this query return all tours without any filtering on

Display 1st paragraph within Advanced Custom Fields

牧云@^-^@ 提交于 2019-12-12 02:25:12
问题 How do you display only the first paragraph of an advanced custom field. <?php the_field('lyrics'); ?> Above is what i use to display the full text. 回答1: add_filter( 'wp_trim_excerpt', 'my_custom_excerpt', 10, 2 ); function my_custom_excerpt($text, $raw_excerpt) { if( ! $raw_excerpt ) { $content = apply_filters( 'the_content', get_the_content() ); $text = substr( $content, 0, strpos( $content, '</p>' ) + 4 ); } return $text; } try this code will help you to show first 55 character of your

WordPress Advanced Custom Fields - Random Query Repeater by SubField value

我的未来我决定 提交于 2019-12-11 19:53:57
问题 I'm trying to fetch ONE random row of testimonials, however that row must contain a "true" value for sitewide_display subfield. I can't for the life of me get this to work, this just gives me whatever result it feels like upon refresh. Is there some sort of conflict with using the conditional for the sub-field value (sitewide_display) within the while loop like this? <?php $rows = get_field('testimonials' ); // get all the rows ?> <?php if( $rows ) : // if there are rows, continue ?> <?php

Advanced Custom Fields: multiple checkbox values displaying conditional data

ⅰ亾dé卋堺 提交于 2019-12-11 15:39:17
问题 I'm using Advanced Custom Fields with Wordpress and I’m using the checkbox field to display data depending on what is selected. The return value of the field is set to 'Value'. I have two checkboxes and I’m getting data based on whether one or the other is selected. But is it possible to show data when both checkboxes are selected? For example: <?php $options = get_field('options');?> <?php if( $options && in_array('option-1', $options) ): ?> <p>Option 1 selected</p> <?php elseif ( $options &

Get ACF custom fields values in woocommerce custom email notification

南楼画角 提交于 2019-12-11 13:49:54
问题 If the user Woocommerce changes his data, a mail to the administrator receives a email about these changes. I need to show in this letter the custom fields that I created in the ACF. (In ACF created a questionnaire and put it into a /edit-account) Here is the complete code, based on - Send notification email when customer changes address WooCommerce if( !class_exists('WooCommerceNotifyChanges') ){ class WooCommerceNotifyChanges{ function __construct(){ // customer saves main account data add

Illegal string offset for 'url' when using WordPress Advanced Custom Fields

大兔子大兔子 提交于 2019-12-11 13:23:15
问题 I am converting a Bootstrap template into a WordPress theme. For custom fields I am using the plugin Advanced Custom Fields . The issue is when I am trying to add an image with the help of Advanced Custom Fields , I get the following error: Warning: Illegal string offset 'url' in C:\wamp64\www\my-site\wordpress\wp-content\themes\bootstraptowordpress\page-home.php on line 31 However when I am adding text through this plugin it shows no error . I have no other plugins installed other than ACF.

Wordpress acf when save post

主宰稳场 提交于 2019-12-11 12:54:53
问题 When I save the post It create one post with correct value and an other with no title and no value! add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post' ); function tsm_do_pre_save_post( $post_id ) { // Create a new post $post = array( 'post_type' => 'itemfounds', // Your post type ( post, page, custom post type ) 'post_status' => 'draft', // (publish, draft, private, etc.) 'post_title' => 'Δωρεά σε είδος για το "'.get_the_title(wp_strip_all_tags( $_POST['acf']['field_5696694332974'] )).'"

ACF Update Field into nested repeater field

天涯浪子 提交于 2019-12-11 10:47:38
问题 I'm trying to let users post from the front end into a nested ACF repeater field. I've got the sub fields in the first repeater posting fine. But, I can't quite figure out how to get the nested repeater working properly. Here's the code I have so far: $event_field_key = 'field_535e6b9ffe3da'; $events[] = array( 'start-date' => $startDate, 'end-date' => $endDate, 'notes' => $_POST['p'.$p.'-notes'], 'start-end-times' => array( 'start-time' => '09:00', // would be dynamic 'end-time' => '17:00' /