Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Update. I have now improved this to be an associate array instead:

    function updateoptionkeys() {
      $fields = array (
        "field_515d9fcb5bee9"=>0,
        "field_515d933e4347c"=>50,
        // etc...
      ); 
      
      foreach ($fields as $key=>$value) { 
        update_field($key, $value, "options");
      }
    }
    
    function myactivationfunction($oldname, $oldtheme=false) {
      updateoptionkeys();
    }
    add_action("after_switch_theme", "myactivationfunction");

    But this means it will revert back to default values everytime the user switch on/off the theme…

    Doesn’t get_field() work with field keyvalues instead of id/name anymore?

  • I thought this might’ve worked; but throwing out an undefined variable…

    $end_date_passed_check = DateTime::createFromFormat('Ymd', get_field('event_end_date'));
    	
    if ($end_date_passed_check < date('Ymd'))
    {
        $date_passed = 'date-passed';
    }

    <div class="each-programme-content <?php echo $date_passed; ?>"></div>

  • Current approach:
    (in functions.php)

    // Update option keys on theme activation
    function updateoptionkeys() {
      // BASE
      if (!get_field("field_515d9fcb5bee9", "options")) {update_field("field_515d9fcb5bee9", 0, "options");}
      if (!get_field("field_515d933e4347c", "options")) {update_field("field_515d933e4347c", 50, "options");}
      //...etc
    }
    
    // When switching Theme Hook
    function myactivationfunction($oldname, $oldtheme=false) {
      // IF Theme options is not set, do set/update them when activating theme
      updateoptionkeys();
    }
    add_action("after_switch_theme", "myactivationfunction");

    For some reason this approach doesn’t seem to work with the latest v. of WP & ACF…

  • Thanks, Elliot. Really appreciate the quick response!

  • Hi @thoughtspacewebsites

    As for your second comment, do I refer support clients to pre written articles, yes, of course I do.

    I don’t believe I have treated you unfairly, sorry If I have.

    Many support clients ask before searching / reading. It is important for me to ask if they have read the article that seems to be what the original question is

  • This is incorrect:

    
     name="' . $field['name']['textarea_2'] . '" >'
    

    It should be:

    
     name="' . $field['name'] . '[textarea_2]" >'
    

    There is a major different between the 2

  • Hi @elliot,

    Here is the data from ‘postmeta’ table.

    a:11:{s:3:"key";s:19:"field_51f95d72c7c5a";s:5:"label";s:4:"Date";s:4:"name";s:4:"date";s:4:"type";s:11:"date_picker";s:12:"instructions";s:36:"Please select the date of your event";s:8:"required";s:1:"0";s:11:"date_format";s:3:"Ymd";s:14:"display_format";s:8:"dd/mm/yy";s:9:"first_day";s:1:"1";s:17:"conditional_logic";a:3:{s:6:"status";s:1:"1";s:5:"rules";a:1:{i:0;a:3:{s:5:"field";s:19:"field_51f846266fda1";s:8:"operator";s:2:"==";s:5:"value";s:6:"Events";}}s:8:"allorany";s:3:"all";}s:8:"order_no";i:4;}

  • Hi @dparadis

    This is possible by querying WP for the posts, then looping through them and rendering the ACF data.

    1. Query WP for a post type (product) – please consult google
    2. Loop through the posts
    3. For each post (product), render the ACF data as per normal.

    Here are some examples which will help:
    * http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/
    * http://www.advancedcustomfields.com/resources/getting-started/code-examples/

    Note: Within your loop, you can use a function called get_the_ID() to get the ID of the current post. Use this value to load the ACF data (second parameter of the_field / get_field)

  • Hi @RichB

    Thanks for the screenshot.

    Adding a select for the taxonomy is on the to-do and you can expect to see it soon.

    ACF contains a filter which you can use to modify the WP_Query args and filter the posts. You can read more here:
    http://www.advancedcustomfields.com/resources/tutorials/customize-the-relationship-field-list-query/

  • Hi Elliot,

    I’ve read this page multiple times. No references are made as to whether or not it’s physically possible to include the premium addons (separate downloads) with ACF Lite (a plugin added through the themes directory). It’s clear that licensing allows for it, but not the interaction that’s created. I see no definitive guideline as to how to incorporate a premium add on with ACF Lite anywhere. Please feel free to show me where this is written.

    Maybe I wasn’t clear enough. I’m trying to figure out how ACF premium addons interface with ACF Lite. Do I have to download the add on, install, set up my fields, and then export the PHP? Then, when one of my clients installs the theme, are they required to install the premium add on also? Should I include the add on in the theme folder?

  • Hi @aaronrobb

    Unfortunately I can’t be of much help on this one as I am not the developer of this add-on.

    Perhaps you could post this question on the github repo / wp plugin support forum?

  • There is a documentation article which covers exactly this:

    http://www.advancedcustomfields.com/resources/getting-started/including-lite-mode-in-a-plugin-theme/

    Not to be rude, but did you search before posting this question?

  • Hi @aldoreyes

    This is a bit of a tricky one, but is possible with some logic as such:

    1. Search the wp_postmeta table for any rows which have a value of $post_id

    2. Delete these rows!

    The database query will have to be a custom FIND sql statement, but this is easy to create thanks to the wpdb functions. You can read more about this here:

    http://codex.wordpress.org/Class_Reference/wpdb

  • 
    <?php
    $args = array( 'post_type' => 'speakers', 'posts_per_page' => 10 );
    $loop = new WP_Query( $args );
    
    while ( $loop->have_posts() ) : $loop->the_post();
    	echo '<div class="entry-content">';
    		echo '<h2 class="speaker-name">';
    			the_title();
    		echo '</h2>';
    			
    			$attachment_id = get_field('field_name');
    			$size = "thumbnail"; // (thumbnail, medium, large, full or custom size)
    			$image = wp_get_attachment_image_src( $attachment_id, $size );
    			
    			
    			echo '<img src="' . $image[0] . '" />';
    			
    			echo '<span class="speaker-title">';
    				the_field('title'); echo ' / '; the_field('company_name');
    			echo '</p>';
    			
    			the_content();                    
    	
    	echo '</div>';
    
    endwhile;
    ?>
    

    Straight from the image field docs. Please read the docs

  • Hi @Patrik

    Thanks for the feedback. I understand the frustration but let’s clear a few things up:

    1. This support forum is a free service provided by me (Elliot Condon) to anyone who wishes to use it, paying customer or not.

    2. To ask me to work 7 days a week providing feedback is a bit much. I don’t ask that of you, and I never would.

    3. To simply log off means that come Monday morning, I would have 3 days worth of support tickets to address. Sorry mate, but I do want to have a life.

    I’m appreciative that you are a customer and user of the ACF plugin, but being a human being on the planet earth, I think I deserve my weekends to enjoy with family and friends.

    Thanks
    Elliot

  • Closing the ability to open a new support ticket during weekends is just silly. The internet does not close like a store or the old phone support. If you don’t want to see new questions during the weekend, there’s a simple solution for that: Log off. Turn off email notifications. It’s really simple.

    Now I – a paying customer – have to wait until Monday to ASK my question, instead of merely waiting for the answer.

  • thank you very much, now this works:

    <?php
    global $wp_query;
    $postid = $wp_query->post->ID;
    echo get_post_meta($postid, 'country', true);
    ?>
    
    <?php $country = get_post_meta($post->post_parent, 'country', true); 
    echo $country;
    ?>
    
    <?php
    global $post;
    $parent = $post->post_parent;
    $grandparents = get_ancestors( $parent, 'page');
    $country = get_field( 'country', $grandparents[0] );
    echo $country;
    ?>
  • Awesome. It works. What if I want to use attachment_id instead of Image URL? It would be great to only show a thumbnail version of the image no matter what size of photos users are uploading.

    I know this is this the code:

    $attachment_id = get_field('field_name');
    $size = "thumbnail"; // (thumbnail, medium, large, full or custom size)

    but how do I fit this in my loop?

    Thanks

  • For anyone else who may have this same issue. I just added

    require_once('/path/to/wp-load.php');

    at the top of my script. Then I run the script via cron. Works like a charm. This is not in functions.php and it’s not run by wp_cron. It’s simply a php file with the line above and my code nothing more.

  • Edit the two functions above as I did and all should work.

    WP filters need return statements (unless the NULL value is desired).

    Hopefully an update will come our way soon, but in the meantime, you will have to be comfortable with editing the plugin itself.

    Already submitted a pull request ( hopefully I didn’t miss anything ):

    https://github.com/elliotcondon/acf/pull/131

  • @admin, is there any chance that this can be resolved in future versions of ACF or is this something I should bother pleasantly request WP-Engine look into.

    Turning off caching is doable while in development, but I’d like to avoid it when the site is in production.

  • Hi @udapud

    In the admin at the bottom underneath where you are adding the new HTML / WYSIWYG fields there should be an area called ‘location’ here you can set rules which decide where the new fields you have just created will appear.

    You will need to select ‘Post Type’ – ‘is equal to’ – ‘NAME OF YOUR CUSTOM POST TYPE’

    When your client edits one of the custom posts they will see the new WYSIWYG.

    You can call it in the custom post template with

    the_field('YOUR FIELD NAME')

    Hope this helps
    Rich

  • Elliot,
    Thanks for helping. Here’s a more specific example. If my custom fields are “Product”,”Size”, “Color” and on a given Product page I render:

    Product: Mens’ T-Shirt
    Size: XL
    Color: Blue

    I can do that part no problem. What I’d like to have is a “Master” page that would render a list of all the custom fields from a group of pages like this:

    Product Size Color
    Men’s T-Shirt XL Blue
    Men’s T-Shirt L Blue
    Men’s T-Shirt M Blue
    Men’s T-Shirt XL Red
    Men’s T-Shirt L Red
    Woman’s T-Shirt XL Green
    Woman’s T-Shirt L Green

    I’d then make the list links to their respective pages. All I’ve been able to find so far are repeating (or looping) custom fields on a single page, not grabbing data from other pages to create an aggregate list.

    David

  • Yeah fix does the trick. Interesting question about 4.1.8 and in 4.2

    Thanks tomsel

Viewing 25 results - 20,876 through 20,900 (of 21,330 total)