Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • parent post have a filled broschuren-download file-field? (no subfield of a repeater/flex!)
    do you use id or url or object at file-field?

    and what are the values of the different variables?

    <?php
    $post_ID = get_the_ID();
    echo ' id:'. $post_ID;
    $parentpost_id = wp_get_post_parent_id( $post_ID );
    echo ' parentid:'. $parentpost_id;
    $attachment_id = get_field( "broschuren-download", $parentpost_id ); //use parents-post field: "broschuren-download"
    echo ' attachment_id:'. $attachment_id;
    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id );
     ?><div class="pdf-download"><a href="<?php echo $url; ?>" >Broschüre herunterladen</a></div>
  • maybe that works / help you

    <?php
    $post_ID = get_the_ID();
    $parentpost_id = wp_get_post_parent_id( $post_ID );
    $attachment_id = get_field( "broschuren-download", $parentpost_id ); //use parents-post field: "broschuren-download"
    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id );
     ?><div class="pdf-download"><a href="<?php echo $url; ?>" >Broschüre herunterladen</a></div>
  • The reason why is that you don’t have the post_id and ACF can’t get the post_id. You will need to somehow supply the post_id to the script that’s creating the CSS.

    you can get the post ID in the head of a single post like this

    
    $queried_object = get_queried_object();
    $post_id = $queried_object->ID;
    

    I don’t know you can get that to the php file, how are you calling it?

  • Thanks so much for taking the time to help me out! The above solution worked perfectly.

    My only question now is, could I show a different “Submit” button conditional on whether or not a date was selected. For example if a date is selected show “Schedule” button, if not show “Create Post” button?

    I’ll see if I can figure this out.

    Thanks so much again for the great support.
    Daniel

  • A dev help me with the following code:

    <?php
    $ancestor_id=1843;//this code is wrong
    $descendants = get_pages(array('child_of' => $ancestor_id));
    $incl = "";
    
    foreach ($descendants as $page) {
       if (($page->post_parent == $ancestor_id) ||
           ($page->post_parent == $post->post_parent) ||
           ($page->post_parent == $post->ID))
       {
          $incl .= $page->ID . ",";
       }
    }?>
    
    <ul>
       <?php wp_list_pages(array("child_of" => $ancestor_id, "include" => $incl, "link_before" => "", "title_li" => "", "sort_column" => "menu_order"));?>
    </ul>

    But I think I no have the knowledge to custom it to my needs.

  • Hey John,

    Last question as there seems to have been some confusion on my end. I kept seeing v5 referenced places, but as my ACF lists itself as “up to date” in the plugins section of the back end I thought I was misunderstanding version numbers somehow.

    Do I understand correctly that ACF5 is only available by purchasing a Pro license?

  • Ok, it works with :

    <?php $terms = get_the_terms( $auteur->ID, 'auteur' ); 
    foreach($terms as $term) {
    $term_link = get_term_link( $term );
    echo '<a href="' . esc_url( $term_link ) . '">' . $term->name . '</a>';
    } ?>

    Thank you John

  • This reply has been marked as private.
  • I’m not entirely sure how to do that / what that means?

    I see from the documentation that altering the capability does the following:

    “Capability used for ACF post types and if the current user can see the ACF menu item. Defaults to ‘manage_options’. Added in v5.1.9”

    And is expecting a string. What I don’t understand, is this checking to see if the current user has the capability defined by this filter and displaying / hiding the menu accordingly?

    Can someone provide me an example? Would it be something like:

    add_filter('acf/settings/capability', 'edit_posts');

    Additionally, is this all that is required or is a combination of using the capability filter along with the show_admin filter required? I’m currently testing both of these but would appreciate feedback so I can learn and understand why this does or does not work.

  • This reply has been marked as private.
  • I just did a quick test and didn’t have any problems adding nested flexible fields in either a flexible field or a repeater.

    Can you describe what happens when you attempt to add nested flex fields.

  • Using the last example from the OP, it is almost there. The correct post_id value needs to be given for all get_field() calls when dealing with anything that is not a “post”.

    
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    $post_id = $taxonomy.'_'.$term_id
    
    $custom_field = get_field('show_medsafe_id', $post_id);
    
    if ($custom_field) {
      echo 'NZ Medsafe ID: '.get_field('medsafe_id', $post_id);
    }
    
  • You need to filter the capability required to manages posts, http://www.advancedcustomfields.com/resources/acfsettings/

  • I just did a quick test and I’m not seeing this issue. Have you tried disabling other plugins or changing to a default theme to see if they could be causing the problem?

  • I can understand your frustrations a bit, but I can also guess to some degree the developer’s thinking is that it works consistent with the way update_post_meta() works and update_field() is just a wrapper for update_post_meta().

    Returns meta_id if the meta doesn’t exist, otherwise returns true on success and false on failure. NOTE: If the meta_value passed to this function is the same as the value that is already in the database, this function returns false.

    Maybe when he gets time he’ll add it to the documentation. I’m also assuming that since update_field() does not mention returned values that it’s not expected that anyone would be testing the returned value. The function is not going to “Fail”, after it is called the field value for the post_id will be set to you want to update it to, one way or another.

  • This weekend I started looking at the available plugins for reusable field groups. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It works a bit differently than the others, it works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. This only works in ACF5, ACF4 does not support acf_local().

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • This weekend I started looking at the available plugins for reusable field groups. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It works a bit differently than the others, it works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. This only works in ACF5, ACF4 does not support acf_local().

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • This weekend I started looking at the available plugins for reusable field groups. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It works a bit differently than the others, it works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. This only works in ACF5, ACF4 does not support acf_local().

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • This weekend I started looking at the available plugins for reusable field groups. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It works a bit differently than the others, it works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. This only works in ACF5, ACF4 does not support acf_local().

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • This weekend I started looking at the available plugins for reusable field groups. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It works a bit differently than the others, it works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. This only works in ACF5, ACF4 does not support acf_local().

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • I started looking into making a reusable field group field after my last comment. Testing and research turned into an entire weekend and at the end I had created my own version of a reusable field group field.

    It only works with ACF5. It works by rebuilding field groups that include a reusable field group field ans local field groups which override the original field groups. The reason it only works with ACF5 is that acf_local() is not available before 5.

    I have not completely tested it and would be interested in feedback or bug reports. I’ll also answer question. There’s not documentation yet, mostly because I think that the instructions when creating the field are pretty self explanatory.

    https://github.com/Hube2/acf-reusable-field-group-field

  • Cool! Yeah the post object is much easier to manipulate if you only require one..
    Since ACF started to use select2 for the dropdowns it’s just as easy to use as the relationship field.. (earlier on I used to utilize relationship field even if I only needed 1 due to the interface).

    Best of luck in your project!

  • Hey!

    So you’re sort of twisting and turning the query around. You start off with terms which you use to query posts which then are used to show terms.

    Your code is a bit confusing.. I’ll post a cleaned up version here but first I want to talk about what it does.

    So with the current code you fetch ALL terms in the taxonomy systemcontents_category2. You then loop through each term and perform a wp_query which fetches all posts connected to that term.

    Then you loop through each post and output the terms name and some information from the post.

    Nowhere is $selected being used and I don’t quite get what it is you want to use it for either. You should also be using ACFs API functions like get_field() to fetch the meta values for the post.

    If this is not what you need please try to explain further and possibly include a screenshot of your ACF setup.

    
    <?php
    $member_group_terms = get_terms('systemcontents_category2');
    $selected = get_sub_field('system_contents_posts');
    ?>
    <?php foreach ( $member_group_terms as $member_group_term ) endforeach; ?>
    
    	<?php
    	$args = array(
    		'post_type' => 'pj_systemcontents2',
    		'posts_per_page' => 400, //unlikely high
    		'tax_query' => array(
    			array(
    				'taxonomy' => 'systemcontents_category2',
    				'field' => 'slug',
    				'terms' => array( $member_group_term->slug ),
    				'operator' => 'IN'
    			)
    		)
    	);
    	$member_group_query = new WP_Query($args);
    	?>
    	<?php if ( $member_group_query->have_posts() ) : ?>
    		<h3><?php echo $member_group_term->name; ?></h3>
    		<?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
    			<?php echo get_field('document-section'); ?>
    			<?php echo get_field('document-reference') . ' ' . get_field('document-sub-section'); ?>
    		<?php endwhile; wp_reset_postdata(); ?>
    	<?php endif; ?>
    	
    <?php endforeach; ?>
    
  • what happens to the data I’ve entered into the field for these pages if I change the location rule to display on posts instead of pages? Is this data still taking space up on the database?

    Yes, the data that was added for posts will still be there.

    Do I have to delete all the field information from the pages before changing the rule so I don’t end up with data I don’t want in the database?

    Deleting what’s in all the fields first won’t do anything except remove the content. The empty content will still be in the database. There isn’t any way to delete the fields completely when you change the locations except to go into the database and do it manually.

    It’s a good idea to plan the development of a site so that once data is entered it does not need to be removed. I think there is a plugin that will convert the post type of a post in WP, in this case you could change your pages to posts and data in the fields will go with it.

  • Thanks, John. That document was helpful.

    For someone else who may stumble across this article and find my query helpful, here it is:

    	$my_query = new WP_Query(array(
            'category_name' => 'artist',
            'posts_per_page' => -1,
            'meta_query' => array(
                'relation' => 'AND',
                'gender_clause' => array(
                    'key' => 'gender',
                    'value' => 'f',
                ),
                'sort_clause' => array(
                    'key' => 'sort_name',
                    'compare' => 'EXISTS',
                ),
            ),
            'orderby' => 'sort_clause',
            'order' => 'ASC',
        ));

    Basically, I am querying posts of the ‘artist’ category, and then selecting those posts where the ‘gender’ (a custom field I have setup) is set to the value of ‘f’. There is another custom field called ‘sort_name’ that I use to order the posts by.

Viewing 25 results - 15,551 through 15,575 (of 21,394 total)