Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • 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

  • Okay, it was a simple fix. Until an patch is released for ACF, you can do the following:

    Open up [WP DIR]/wp-content/plugins/advanced-custom-fields/core/fields/taxonomy.php

    Edit lines 415, 419 and 424 and replace value="' . $term->id . '" with value="' . $term->slug . '"

    Hope that helps. 🙂

  • Thanks Elliot

    I restored a DB backup from before the upgrade.
    Sequentially upgraded as you suggested and everything is working perfectly.

    Thanks for the assistance

  • Thanks for the quick reply, @elliot.

    I don’t believe it’s a server limit. The amount of data I’m trying to save is very small. The only data on the Page (the only data I’m saving) is two instances of a single Repeater Field. Each instance of the Repeater Field contains 9 text fields (retailer name, address, city, state, phone, etc.).

    Whenever I try to add an additional Repeater Field instance, it doesn’t save the new entry upon hitting “Update.” As I said though, it works fine on other sections of my site. It’s only the Retailers section that isn’t working.

    Just a little more info: my retailers section is broken into separate pages, organized by region. New York, Florida, Germany, United Kingdom, France, etc. and each of those separate Pages contains the Repeater Field form. Each page only has a few instances (2 – 3) of the “Retailers” Repeater Field.

    In other words, France for example only lists three retailer locations. It’s not a lot of data.

    I’ll also add this: if I add all the relevant data manually (retailers_1_name, retailers_1_address, retailers_1_city, etc.) using WordPress’s Custom Fields box, everything works fine and it saves the data. It’s just not saving the data when I use the Repeater Field input box.

    I’ll also say that it used to work fine a few months ago (the last time I tried updating the Retailers section). And again, it’s only my Retailers pages that aren’t saving properly, but the other sections where I use the Repeater Field plugin work fine. FAQs, Color Chart, etc.

    Any thoughts based on all this information?

    Thanks again.

  • Here, in the attachment, is my settings for taxonomy fields.

    The bug occurs on regular webhosting as well as on local installation. Both Multisite version of WP 3.6.

    Plugins I’m using:
    Members
    Multisite User Management
    Peter’s Post Notes
    WordPress Importer

    Theme:
    Required+

    EDIT: The bug also occurs on regular clean WP 3.6 installation with Twenty Thirteen theme.

  • I’m sure that a lot of thing missing from my field to work, but i have no idea what.
    Here is my hole field:

    <?php
    class acf_field_year_n_text extends acf_field{
      var $settings, 
        $defaults;
      function __construct(){
        $this->name = 'year_n_text';
        $this->label = __('Year and text');
        $this->category = __("Content",'acf');
        $this->defaults = array(
          'default_value'  =>  '',
          'formatting'   =>  'br',
        );
        parent::__construct();
        $this->settings = array(
          'path' => apply_filters('acf/helpers/get_path', __FILE__),
          'dir' => apply_filters('acf/helpers/get_dir', __FILE__),
          'version' => '1.0.0'
        );
      }
      function create_options($field){
        $key = $field['name'];
        ?>
        <tr class="field_option field_option_<?php echo $this->name; ?>">
          <td class="label">
            <label><?php _e("Formatting",'acf'); ?></label>
            <p class="description"><?php _e("Define how to render html tags",'acf'); ?></p>
          </td>
          <td>
            <?php 
            do_action('acf/create_field', array(
              'type'  =>  'select',
              'name'  =>  'fields['.$key.'][formatting]',
              'name2'  =>  'fields['.$key.'2][formatting]',
              'value'  =>  $field['formatting'],
              'choices' => array(
                'none'  =>  __("None",'acf'),
                'br'  =>  __("auto <br />",'acf'),
                'html'  =>  __("HTML",'acf'),
              )
            ));
            ?>
          </td>
        </tr>
        <?php
      }
      function create_field( $field ){
        ?>
        <table >
          <tr>
            <th scope="col">Year</th>
            <th scope="col">Text</th>
          </tr>
          <tr>
            <?php var_dump ($field['value']); ?>
            <td>
              <?php echo '<textarea 
                id="' . $field['id'] . '" 
                rows="4" 
                class="' . $field['class'] . '"
                name="' . $field['name']['textarea_1'] . '" >'
                  . $field['value']['textarea_1'] . 
                '</textarea>';
              ?>
            </td>
            <td>
              <?php echo '<textarea 
                id="' . $field['id'] . '" 
                rows="4" 
                class="' . $field['class'] . '"
                name="' . $field['name']['textarea_2'] . '" >'
                  . $field['value']['textarea_2'] . 
                '</textarea>';
              ?>
            </td>
          </tr>
        </table>
        <?php
      }
      function input_admin_enqueue_scripts(){
        wp_register_script('acf-input-year_n_text', $this->settings['dir'] . 'js/input.js', array('acf-input'), $this->settings['version']);
        wp_register_style('acf-input-year_n_text', $this->settings['dir'] . 'css/input.css', array('acf-input'), $this->settings['version']);
        wp_enqueue_script(array(
          'acf-input-year_n_text',
        ));
        wp_enqueue_style(array(
          'acf-input-year_n_text',
        ));
      }
    }
    new acf_field_year_n_text();
    ?>
  • Thanks for you quick reply,

    This worked perfectly!

  • So far I just can’t get it done.. I’m trying to get the field “cursusfoto” (see http://d.pr/i/ibk3) set as the featured image. I already set the return value at the ID (I assume that’s right), see http://d.pr/i/q6nJ.

    However, I simply have no clue how to manage this code-wise.. (I’m not a developer).

  • Ah, OK. I’m currently trying to use the default “thumbnail” size available in ACF. However, I’ve tried all the standard size options AFC has and none of them work for me.

    I will try the regenerate thumbnail plugin buy if this worked, presumably I’d have to do this every time an image was added to the site which is not ideal for a client.

    Thanks for the help,
    Nat

    EDIT:

    OK, figured it out. I was using images that were already uploaded into the media gallery to test with so they didn’t have thumbnails create as you quite rightly said. If I upload fresh images it works correctly (uses thumbnail previews)

  • Just an FYI, @elliot, in case you decide to throw the hook in sometime soon, the perfect place for it would be in the html() function in acf-options-page.php on line 480 (by my IDE). It would be just above the form#post opening tag.

    That would make it possible to drop in the following snippet;

    	<h2 class="nav-tab-wrapper">
    		<a href="#" class="nav-tab">Display Options</a>
    		<a href="#" class="nav-tab">Social Options</a>
    	</h2>
    

    I reckon that would be almost perfect for what I’m on about, although it would still only be dropping the tabs underneath the heading (but that is heaps closer to what I’m after, anyhow).

    I would also be awesome if we could create more than one top level ACF options page, as there would be no need to manually create one, as I already have, resulting in a mostly empty page with a few buttons on it… unless I missed something and we can already do so. It wouldn’t surprise me 😀

    Cheers!
    Phil

  • Hi @Permanence

    Have you read the code exmaples for conditional logic / understand what an if statement in PHP is?

    Your code should look more like this:

    
    <?php while(the_repeater_field('content_block')): ?>
    <div class="clearfix">
    <?php if( get_sub_field('title') ): ?>
    	<h2><?php the_sub_field('title'); ?></h2>
    <?php endif; ?>
    <div class="img"><img src="<?php the_sub_field('image'); ?>"></div>
    <div class="txt"><?php the_sub_field('content'); ?> </div>
    </div>
    <?php endwhile ?>
    
  • It is pretty weird huh? I’m absolutely weirded out by this one…

    Okay, the save_post action is commented out and the following debugging statements were added to acf_form_head (results below);

    function acf_form_head()
    {
        // global vars
        global $post_id;
    
        // verify nonce
        if( isset($_POST['acf_nonce']) && wp_verify_nonce($_POST['acf_nonce'], 'input') )
        {
            var_dump($post_id); // OUTPUT: NULL
    
            // $post_id to save against
            $post_id = $_POST['post_id'];
    
            var_dump($post_id); // OUTPUT: string(3) "new"
    
            // allow for custom save
            $post_id = apply_filters('acf/pre_save_post', $post_id);
    
            var_dump($post_id); // OUTPUT: NULL
    
            die();
    
            // save the data
            do_action('acf/save_post', $post_id);
    
            // ...
        }
    
        // ...
    }
  • Hi @dparadis

    Do you mean, have a page which loops through all the 10 pages and displays the custom field value?

    Please be a bit more specific. What does ‘row 1 A B C’ mean in your diagram?
    How does this relate to the choice of a page?

  • Hi @Marzo

    Please read the code examples for the image field:
    http://www.advancedcustomfields.com/resources/field-types/image/

    if your image field returned a simple URL, the following code would work:

    
    <?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>';
    			
    			echo '<img src="' . get_field('field_name') . '" alt="" />';
    			
    			echo '<span class="speaker-title">';
    				the_field('title'); echo ' / '; the_field('company_name');
    			echo '</p>';
    			
    			the_content();                    
    	
    	echo '</div>';
    
    endwhile;
    ?>
    
  • Hi @DanielB

    … kind of like a JSON request

  • Hi @DanielB

    Good question..

    In short, I’m not 100% sure how to do this. You would need to instantiate WP and include the ACF plugin making sure all the correct add-ons and actions were called for the plugin to function.

    Perhaps your cron could just target a url which you could then work from within WP?

  • Hi @timshutes

    The code:

    
    <a href="<?php the_field('page-link') ;?>"><?php the_field('page-link-title') ;?></a>
    

    is missing the $post_id parameter! That is why it is not loading from the child page

  • Hi @NathanD

    Awesome question, simply, yes.

    ACF has an action called acf/save_post.

    You can use this action to hook into the save process and do what you will.
    In your function, you could insert a new post (lots of docs on the internet about wp_insert_post) and use either the $_POST data, or just load the ACF data as normal via get_field (less efficient, but easier to code)

    Cheers
    E

Viewing 25 results - 20,926 through 20,950 (of 21,363 total)