Support

Account

Forum Replies Created

  • Thanks James … but I might need this spelling out a bit.

    Do you mean
    – create a custom post type called growing-instruction, say
    – create a strawberry growing-instruction post with the instructions in the content field

    – in my blog post acf create a new post-object-field which looks for growing-instruction custom post types

    – when I create a post relating to strawberries, I choose strawberry from the growing-instruction post-object-field

    – behind the scenes, I add something to functions.php to grab and display the content from the growing-instruction post-object-field in the post

    I’ve read the documentation and don’t quite understand how I grab info from a post that’s not _this_ post; could you help with this too, please?

  • Thank you very much! No more white screen of death!

    I’m from the curly-bracket school of coding, so have gone for your curly bracket solution.

  • In ACF, I’ve used field-group prefixes on all fields to try to prevent conflicts; these use cg_. Apart from the repeater field, this function is a duplicate of another that works (with a different prefix!).

    I’ve pared down the function enough for you to see how I’ve grabbed other fields and how I’m trying to grab the repeater fields. This shortened version still white-screens when I include the while have_rows line.

    <?php 
        function sal_display_code_grid_item()
        {
            global $post;
            {
                echo( '<div class="outside">');    
    
                echo ( '<div class ="my-header">' );
                $thispicture = get_field( "cg_pretty_picture" , $post->ID );
                echo( '<img src="' . $thispicture . '"/>'); 
                
                echo ( '</div><!-- end header -->' ); //end header
                
                echo( '<div class="inside">' );
                
                /*https://www.advancedcustomfields.com/resources/have_rows*/    
                echo( '<ul>' );
                
                if( have_rows('cg_the_links', $post->ID ) )
                {
                    //tried with and without $post->ID, but I think that I need it
                    while( have_rows('cg_the_links', $post->ID ) ): the_row();  
                    {
                        $thislink = get_sub_field('cg_link_url', $post->ID );
                        $thislinktext = get_sub_field('cg_link_text', $post->ID );
                
                        echo( '<li>' );
            
                        echo( '<a href="' . $thislink . '">' . $thislinktext . '</a>' );
            
                        echo( '</li>' );
    
                    }
    
                }
                echo( '</ul>' );
                
                echo ( '</div>'); //end of inside div
                
                echo( '</div>' ); //end of outside
            }
        }
    ?>
    
Viewing 4 posts - 1 through 4 (of 4 total)