Support

Account

Forum Replies Created

  • Hey Rob,

    Did you ever figure this out, I’m looking for a similar functionality, except I just want to be able to search by the Post ID as well.

  • I found this wp-admin-menu-classes on Github, it works really well! You can pretty much rename, remove and copy any item or section within wp-admin. Very powerful and very handy!

    https://gist.github.com/mikeschinkel/792b7aa5b695d1092520

    That class plus this little bit of code I was able to change the navigation to suit my needs.

    // Change wp-admin menu
    add_action('admin_menu','admin_menu_changes');
    function admin_menu_changes() {
      rename_admin_menu_section('Custom Fields', 'Product Features');
    }
  • BUMP! Need this feature as well…

  • Hey @eileen.schmidtke.

    You’re on the right track there with the logic, you’re just missing a key function to make the check boxes work as conditional options.

    You can find the documentation here: http://www.advancedcustomfields.com/resources/checkbox/

    The part you should look at is this:

    /*
    *  Conditional statement (Checkbox rvalue is an array)
    */
    
    if( in_array( 'red', get_field('field_name') ) )
    {
        //...
    }

    So for your code would look like this … I’ve cleaned it up and commented it a bit as well 🙂

    <aside>
    <?php if ( in_category( 'farrell' )) {
    
    	$rows = get_field('reimburs_links');
    	
    	if($rows) {
    	  echo '<h2>Reimbursement Information</h2>';
    	  echo '<ul>';
        	
        	foreach($rows as $row) {
        	
        	// If Page is checked, use page link and title
        	if(in_array('page', $row['type_of_link'])) {
        	  echo '<li><a href=”'.$row['page_link'].'”>'.$row['link_title'].'</a></li>';
        	}
          
          // If file is checked, use file link and title
        	if(in_array('file', $row['type_of_link'])) {
        	  echo '<li><a href=”'.$row['file_link'].'”>'.$row['link_title'].'</a></li>';
        	}
        	
      	}
      	echo '</ul>';
      }
    } ?>
    </aside>

    Hope that helps.

  • Hey @Tintin,

    You’ll want to create a variable for your string then use a concatenated string -> http://php.net/manual/en/language.operators.string.php.

    $idcode = get_field('id_code');
    echo do_shortcode('[shortcode id="'.$idcode.'"]');

    You could also skip the variable all together and just use the get_field function inline.

    echo do_shortcode('[shortcode id="'.get_field('id_code').'"]');

    Hope that helps. 🙂

    EDIT: Added inline function option.

  • I am running it as a plugin.

  • Ok so I’m making some drastic changes…

    I managed to get the conditions to work fine after I ported these post types to a plugin rather than baking them into the theme. I think in the long run it’ll be easier for myself and the client to manage as plugins anyways.

    Not sure why the filter is not working for the theme, but it works as a plugin… odd.

  • Ok, so I started digging into core/json.php to figure out how to print out the json path array and I found acf_get_setting('load_json'); which I figured is where the paths are stored. However, when I spit out that array I only get 1 array item and it points to the theme acf-json folder, my custom load point is not there.

    I used Debug Bar to verify that the filter was firing and it is indeed (see attached).

    Just to make sure I didn’t mess something up in my code, I used the base filter code that is provided in the documentation and the array still remains intact… just trying to unset the default doesn’t work either. I’m stuck.

  • Hey there @Elliot

    I tried to debug it but I couldn’t get it to return the value to me. I tried adding a print_r($paths) in the load point function, but I’m sure that’s wrong.

    What is the best way to go about doing it?

    Thanks.

  • Right… it’s says “this is only 1” not “this is THE only 1”

    In the example that is written it even states that the unset is optional because it removes the original pathing… which would be to /acf-json.

    I’m not really into using addhandler and inline conditions because I want to keep the save functionality from my local version for when I push updates/adjustments to the field set. I’d wind up having to keep two versions of the file. That’s messy. If it’s the only option though, I may have to go there.

  • Well I don’t want to overwrite the entire array, I’m still using the base acf-json path. I just want to conditionally add the new ones, that’s why omitted the unset.

  • I should have clarified… I had already tried loading via the filter.

    here’s what I had that I couldn’t get to work.

    // Load Data Model type for inventory
    add_filter('acf/settings/load_json', 'my_acf_json_load_point');
    function my_acf_json_load_point( $paths ) {
        $datamodel = get_field('inventory_data_model', 'options');
        
        // append path
        if($datamodel == 'Car') {
          $paths[] = get_stylesheet_directory() . '/acf-json/car';
        } elseif($datamodel == 'Truck') {
          $paths[] = get_stylesheet_directory() . '/acf-json/truck';
        }
        
        // return
        return $paths;
    }

    Does the path have to be outside of the acf-json folder? I didn’t try that.

Viewing 12 posts - 1 through 12 (of 12 total)