Forum Replies Created

  • Even installing one of the SVG plugins makes it possible to upload SVG files to image fields

  • Hi John

    I know in general from reading this thread that it is a very complex issue that will probably not be solved any time soon. What I was referring to was the rather “simple” thing you mentioned of deleting all values in specific fields upon deleting the fields themselves in ACF. You made a useful action for this, but there was a the issue of fields with the same names getting deleted in different groups. That made me wonder why this was an issue if the fields had unique identifiers. 🙂

  • +1

    One thing i noted by reading some of the possible solutions is that it seems to be a problem that custom fields doesn’t have a unique identifier. I don’t get why ACF doesn’t just implement that every field created gets it own unique id regardless of the field name and such. This would make all this much easier. Am I missing something here? 🙂

  • Okay, so I got it working by using different post_object names and by removing the wp_reset_postdata();

    $your_posts = new WP_Query( $args );
    // Loop starts here
    if ( $your_posts->have_posts() ) : while ( $your_posts->have_posts() ) : $your_posts->the_post();
    	// First post from a CPT
    	if( get_field('custom_post') ) {
    		$post_object_cpt = get_field('custom_post');
    		if( $post_object_cpt ) {
    			$post_cpt = $post_object_cpt;
    			setup_postdata( $post_cpt ); 
    			<a href="<?php the_permalink($post_object_cpt->ID); ?>"><?php if(get_field('CPT_name', $post_object_cpt->ID)) { the_field('CPT_name', $post_object_cpt->ID); } ?></a>
    	// Second post from a CPT
    	if( get_field('custom_post2') ) {
    		$post_object_cpt2 = get_field('custom_post2');
    		if( $post_object_cpt2 ) {
    			$post_cpt2 = $post_object_cpt2;
    			setup_postdata( $post_cpt2 ); 
    			<a href="<?php the_permalink($post_object_cpt2->ID); ?>"><?php if(get_field('CPT_name', $post_object_cpt2->ID)) { the_field('CPT_name', $post_object_cpt2->ID); } ?></a>
    endwhile; else: ?><p>Sorry, there are no posts to display</p>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    Can anyone please tell me if this is the correct way of doing it?

  • Hi John

    Thank you for your answer. Unfortunately it didn’t solve my problem adding the $post_object->ID. I read the post you linked to and I understand the problem. You suggest to use alternate means of getting values other than setup_postdata, can you give any examples of this?

  • I want to note that if I remove the first “custom_post”, it will display “custom_post2”.

    Also, should I use
    <?php wp_reset_postdata(); ?>

    Instead of

    <?php wp_reset_query(); ?>

    In the end?

  • Hi John

    Thanks for your answer.

    Yes you are right, the links are stored in their own tabel. But the relationship, term etc. is the same as with other post types. Only they refer to the link table instead of post table. Do you think it is an impossible task?

    Do you have some suggestions on other ways I attach links to posts and manage them from one place? 🙂

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