-
yonatan
On this page: https://ivhome.seo-guide.co.il/ there is a query loop that shows posts related to a specific category. I want to create CSS rules for each post (for example: a unique color for the title of each post) but there doesn’t seem to be a unique id for each box container in the loop, or an option to add on. How can I solve this?
Thank you,
Yonatan. -
Hi there,
try this PHP Snippet:
add_filter( 'generateblocks_attr_grid-item', function( $attributes, $settings ){ if ( $settings['isQueryLoopItem'] && !is_admin() ) { $attributes['ID'] = 'uniqueID-'.get_the_id(); } return $attributes; }, 10, 2 );
-
yonatan
Hi David and thank you for your quick response 🙂
Should I paste this snippet in functions.php?
After I paste this, should I see an ID for each section inside the loop when I inspect the page with google dev tools?
Thank you. -
yonatan
Anyway, I added the code to functions.php and I see no change on the backend or the frontend..
-
Alvind
Hi there,
The code should work: https://app.screencast.com/pevQIPN1lO5u5
Could you confirm if you’ve added the snippet correctly?
-
yonatan
Hi Alvind – I pasted it inside the functions.php file. Is there a different file to paste it in?
Tnx. -
Alvind
Yup, that should works. Try this – duplicate the existing query loop block on the page, and delete the old one.
-
yonatan
Hi, no change – here are the code and the snippet:
https://ibb.co/hFWzXBw
https://ibb.co/8P03rdW -
Alvind
The snippet is correct. The only possible reason for it not working is if you’re activating the parent theme instead of the child theme. I assume that’s not the case?
Alternatively try using a Code Snippets plugin:
https://wordpress.org/plugins/code-snippets/ -
yonatan
Hi,
I activated the plugin and added the code – no change. -
Could you provide us a temporary admin login so we can take a closer look ?
-
yonatan
Hi David,
Sure, added inside the private information section.
Thank you. -
The password is incorrect, can you check?
-
yonatan
Changed it,
Please try again.
Thank you. -
Alvind
Would you mind if I temporarily change your site language to English for me to debug the issue?
-
yonatan
No problem.
- You must be logged in to reply to this topic.