Archived topic
php Code issue
7 replies · Started by Dominic on March 5, 2021
Hi
I am trying to add this code to the contents.php template:
<div> class="bib--rcm-init"
data-recommendation-key="2f708a85-433a-4eba-b606-117b34bde3cd"
data-query-string-params="Bibblio_source=true"
data-style-classes="bib--default bib--font-arial bib--size-18 bib--recency-show bib--car-6 bib--4by3 bib--shine bib--image-top"
>
</div>
I keep getting the critical error after it has been added and when i turn on wp debug i get Parse error: syntax error, unexpected '<', expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF)
This is not my code i need it to track some things on my site.
Does anyone know how i can correct the code to make it right or is it just bad code?
Thanks.
Hi there,
unless you're using a child them and you have made a copy of the contents.php you should NOT edit the theme files.
Where in the content do you want that element to be added ?
Hi,
From line 41:
to start here
/**
* generate_after_entry_title hook.
*
* @since 0.1
*
* @hooked generate_post_meta - 10
*/
do_action( 'generate_after_entry_title' );
?>
</header>
<?php
endif;
I have added this code and made an element and the widget shows up but this code needs to be here so the analytics for the widget can be tracked.
Not sure if I understand.
Have you reverted the content.php back to the original state?
Yes I had to put it back to original state and take the above code of. I wanted the code to start from line 41 and be inserted from there, but then after it was placed it was throwing an error on my archive pages only.
Have you tried using the generate_after_entry_title with a hook element?
https://docs.generatepress.com/article/hooks-element-overview/
Hi
Yes this is how i inserted the code in the first place and the company said it needed to be in the theme to work. I said nope this was the way to do it as it was messing up my archive pages.
So after a while the code is actually working now where i put it in the first place. Thanks for the help.
No problem :)