New answers tagged

0

ACF is a third-party plugin and I don't know what functions it gives you that you could use. In general, though, you can create a query for posts with a particular custom field and value. $args = array( 'meta_key' => 'featured', // must match the key that ACF has used 'meta_value' => true, // must match the value that ACF has used '...


0

I found a Notice error in your code. You have used $description in your code. Initially you have not defined it and directly using concatenation to it. function label_text( $post_id = '' ) { $description = ''; while( have_rows('description', $post_id) ): the_row(); $description .= get_sub_field('label') . get_sub_field('...


0

If I understand your question correctly, I believe this is what you're looking for: <div class="postthumbnail"> <?php $usercrop = get_field('usercrop'); if ($usercrop) { $image = wp_get_attachment_image_src(get_field('usercrop'), 'full'); ?> <img class="post-thumbnail img-responsive postpic" src="<?php echo $image[...


0

Have you set a static page as your blog home page? You can do this under Settings > Reading. Otherwise get_option('page_for_posts') won't work.


0

The way I solved this, was to set up a custom post type set up for each of the default images I wanted, then pulled in the post with the featured image associated with each.


0

$val = get_post_meta( get_the_ID(), 'meta_data_name', true ); echo $val; You can replace get_the_ID() with the ID of the post you are getting the meta from. You could possible team this with: $frontpage_id = get_option('page_on_front'); to get the homepage ID. Not sure if this would be friendly with multisite though. the_field() is an Advanced Custom ...


1

Remove return; from your code, which is prematurely exiting the function before the following two lines can be executed; that is why the status is not changed. function my_change_status_function () { global $post; $ordernumber = get_post_meta( $post->ID, 'order_number', true ); $audit_status = get_post_meta( $post->ID, 'audit_status', ...


0

in the action request, the keys meta_key and orderby already exists then try to overwrite like this : if ( isset( $vars['orderby'] ) && 'count' == $vars['orderby'] ) { $vars["meta_key"] = "count"; $vars["orderby"] = "meta_value_num"; }


1

I copied your code to one of my sites to test with ACF version 5.3.9.2. And it works for me I just had to make sure the field name and image size were correct. $size = get_field('slideshow_size') ?: 'Panoramic'; // Make sure this size exists, and usually is all lower case. $column_id[ $i ] = $row['slideshow-image']['id']; // Field names in ACF normally ...


1

You need to make the whole line conditional, like this: $sub_field_title = get_sub_field('title'); if (!empty($sub_field_title)) { echo '<h1 class="title">' . $sub_field_title . '</h1>'; }


0

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 import users and to better modify advanced custom fields associated with CPT's as well.


0

It's not working, keeps giving me data from reviews of all consoles: Mortal Kombat from SNES and arcade are counted as "two reviews for Mortal Kombat" at the SNES page of the game... It IS working. The code is OK, I have just make a minor mistake: there was two reviews under "snes" category, I forgot to change one of them when testing. I've added only ...


1

Arrays are serialized by default, so just do update_post_meta($my_post, 'ganalytics_settings', $ganalytics_settings); https://codex.wordpress.org/Function_Reference/update_post_meta $meta_value (mixed) (required) The new value of the custom field. A passed array will be serialized into a string.(this should be raw as opposed to sanitized for ...


6

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 should you ever wish to move away from VC and/or change the layout. To elaborate, "VC vs ACF" isn't really a question - they are two completely different ...



Top 50 recent answers are included