Site logo

Archived topic

Query loop layout

22 replies · Started by Niek on July 29, 2022

Viewing posts 16–23 of 23

Hi Dave,
Thanks for your help again!
I followed all your steps, but it does not seem to replace the placeholder i select

It won't in the editor unfortunately - does it work on the front end ?

That it does not work on editor is fine.
Unfortunately, it also does not work in front end. See private info for link.

Hmmm... i assume you changed the URL path, in the code, just out of interest can you add the exact code i provided? as on my local dev site it is grabbing the category term.

Ah yea i did change the path.
The code i have now is:

function db_category_image( $block_content, $block ) {
    $id = get_the_ID();
    $category = get_the_category( $id );
    $cat_name = $category[0]->cat_name;
    if ( ! empty( $block['attrs']['className'] ) && 'cat-image' === $block['attrs']['className'] ) {
        $block_content = '
		<figure class="gb-block-image has-cat-image">
		<img class="cat-image" src="images/category/'.$cd->cat_name.'.webp" height="60" width="100" />
		</figure>
		';
    } 
    return $block_content;
}

Whats the $cd variable for ?
ie. seen here ?

<img class="cat-image" src="images/category/'.$cd->cat_name.'.webp" height="60" width="100" />

Ah men, i f'd up.
I copied the html with from your last code and that had another variable in it.
I now changed that to the correct $cat_name and it's working.

Thank you so much! You guys are legends!

Awesome - glad to hear thats working :)

This archived topic is closed to new replies.