Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

ACF and GB Pro / GP Pro

  • Sorry me again – I am still struggling to understand the ACF / GB Pro blocks, hopefully I can explain better what I am looking for.

    So I have ACF set up and I have added a new field group called School Categories, and set it to ask extra questions on the product category pages, namely 2 images, a name and a colour

    I can display these fields within the template using <h3><?php echo $sch_name; ?></h3> etc which works – as you can see from link shown there is duplicate names and images – great

    BUT I really wanted to use elements to do this rather than styling in the template..

    This is where I am coming unstuck, I have created a ELEMENT BLOCK and used content template as the type, location product categories archive. It then asks apply to – this is only to display on product category pages so should I select posts with term and product_cat or something else? As it then asks for term name – is that the acf field name?

    I am definitly not understand the taxonomy / term and what they are actually meaning here…

    So assuming that I get that part right I have then gone in and inserted a headline and using the sidebar dynamic data, I have

    data source – current post
    content source – post meta
    post meta field – now this is where I was expecting to see the ACF fiel details – but I can see _acf_changed and generate stuff but that is it…

    On reading other posts – as I have been trying to learn myself honest!! – I saw that I must ensure ACF was using REST API – so in GROUP SETTINGS in ACF I ticked SHOW IN REST API – it then asks for a description and I entered School Categories… expecting that to appear..

    but it didn’t

    I also added a couple of shortcodes [acf field="school_name"] and that is not showing either – so I think I have the element type wrong

    I have also tried post meta template – which does at least show on the correct page – you will see 123456 that is just plain text being pulled through from same element .. but the ACF fields still nada…

    So any assistance greatly appreciated! as I am proper in a muddle here.. but if I can get this to work then that would save me heaps of time and effort!

    Thank you

  • I am definitly not understand the taxonomy / term and what they are actually meaning here…

    It’s basic WP knowledge, you should be able to find lots of info on this.

    Taxonomy is a way of organizing things into groups or categories based on shared characteristics. In WordPress, taxonomy is used to organize and classify content types like posts, pages, and custom post types. It helps in organizing content in a structured manner, making it easier to manage and navigate.

    Terms, on the other hand, are the individual categories or labels within a taxonomy. They represent the specific groups or classifications that content can be assigned to. For example, if “Genre” is a taxonomy for movies, then terms within this taxonomy could be “Action,” “Comedy,” “Drama,” etc. Terms are like the subcategories or labels that content is assigned to within a taxonomy.

    It sounds like you are trying to pull the term meta, not post meta.

    GenerateBlock’s dynamic data (in the sidebar) does not support term meta, you need to use GP’s dynamic data option in the floating toolbar, here’s a screenshot for your reference:

  • Thank you Ying – I used the floating toolbar and that worked – for the school name – so yeah! however I can now see that that will not work for images – as they only use post meta not term meta..

    So I will just do all of this in ACF instead and just accept that BG/GP is not going to work for me in this instance – gutted but is what it is.

    Oh and I get the wordpress terms and taxonomy – I should have made it more clear that its so many ways of pulling data dynamically in GB and GP that I am finding confusing as I cannot locate the logic and the terminology used there

    anyway i have flogged this horse enough and will find an alternative route – thank you

  • I can now see that that will not work for images – as they only use post meta not term meta..

    That’s right, there’s no built-in option to pull term meta for images.

    But you can use PHP code to create a shortcode:

    add_shortcode( 'category-image', function() {
        $term_id = get_queried_object_id();
        // Change the meta key "image" to the actual term meta key
        $image_id = get_term_meta( $term_id, 'image', true );
        // Get the URL of the image attachment, change full to the size you want
        $image_url = wp_get_attachment_image_src( $image_id, 'full' )[0];
        // Output the image
        echo '<img src="' . esc_url( $image_url ) . '">';
        return ob_get_clean();
    } );

    Adding PHP:

    2. Add this shortcode [category-image] to where you want the image to appear.

    Hope this helps 🙂

  • ok interesting – not seen that floating around – I have already compeleted it usinG ACF but I will certainly take a look at that – thank you

  • No Problem 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.