Support

Account

Forum Replies Created

  • Just a quick one to say I’ve figured it out, at long last.

    All I had to add was the following line:

    echo get_the_post_thumbnail( $queried_post->ID, 'thumbnail' );

    DONE!

    Thanks for your help.

  • Hi John,

    Thanks for getting back to me.

    Fortunately, I was able to echo out the post content based on the ACF drop-down selection. I had to make a couple of alterations for this to work though, so it’s not as automated as I was hoping for.

    So basically I changed the custom field type from Post Object to Select and just inserted a list of post IDs along with their respective guide names.

    I then altered the PHP in functions to this:

    //Add a guide
    add_action( 'woocommerce_product_thumbnails', 'gotread_guide', 110 );
    
    function gotread_guide() {
    	echo '<div class="row clear">';
    	echo '<div class="col-4">';
    
    	echo '</div>';
    	echo '<div class="col-8">';
    		$guideid = get_field('choose_your_guide', false, false);
    		$post_id = $guideid;
    		$queried_post = get_post($post_id);
    		$title = $queried_post->post_title;
    		echo $title;
    		echo $queried_post->post_content;
    	echo '</div>';
    	echo '</div>';
    }

    A new variable of $guideid was added which was equal to get_field('choose_your_guide', false, false); I realised it wasn’t working before because it was echoing the ID as a string rather than a number so adding false to the $format_value parameter stopped this. Which is pulling out both the title and the post content. Which is great, but you’re right I am having trouble with the images.

    I want to echo out the featured image. How would you recommend I go about this using JavaScript?

  • In case anybody was wondering, I’ve managed to fix it. Turns out it was because I was trying to echo PHP through PHP. I’ve updated the code to the following and it’s working.

    
    add_action( 'woocommerce_single_product_summary', 'ngt_accordion', 11 );
    
    function ngt_accordion() {
        echo '<div id="ngt-accordion">
                <ul class="nav">
                    <li><a href="#">Aviator\'s Notes</a>
                        <ul>
                            <li>';
    
                            the_field("aviators_notes");
    
        echo '</li>
                </ul>
                    </li>
                    <li><a href="#">Product Overview</a>
                        <ul>
                            <li>';
    
                            the_field("product_overview");
    
        echo '</li>
                </ul>
                    </li>
                    <li><a href="#">Size & Details</a>
                        <ul>
                            <li>';
    
                            the_field("size_and_details");
    
        echo '</li>
                </ul>
                    </li>
                    <li><a href="#">Care Instructions</a>
                        <ul>
                            <li>';
    
                            the_field("care_instructions");
    
        echo '</li>
                </ul>
                    </li>
                    <li><a href="#">Delivery & Returns</a>
                        <ul>
                            <li>';
    
                            the_field("delivery_and_returns");
    
        echo '</li>
                        </ul>
                    </li>
                </ul>
         </div>'
     ;}
Viewing 3 posts - 1 through 3 (of 3 total)