
Tagged: functions, schema markup, structured data
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
August 4, 2025 at 5:59 am #1487532
I need to add some structured data (schema markup) to 1 page only, lets say the homepage, but maybe to another ones.
An example for google:
<script type="application/ld+json"> { "@context": "https://schema.org/", "@id": "https://www.example.com/advancedCpp", "@type": "Course", "name": "Learn Advanced C++ Topics", "description": "Improve your C++ skills by learning advanced topics.", "publisher": { "@type": "Organization", "name": "CourseWebsite", "url": "www.examplecoursewebsite.com" }, "provider": { "@type": "Organization", "name": "Example University", "url": "www.example.com" } </script>
How can I add that just to 1 page (homepage) or another page using functions?
Thank you.
August 4, 2025 at 6:48 am #1487538Hey peterolle,
Thank you for the inquiry.
You can use the wp_head or wp_footer hook to add the script to a specific page.
Example:
function ava_json_ld_mod() { /// replace placeholder slug-of-your-page with the actual slug or ID of the page if (is_page('slug-of-your-page')) { ?> <script type="application/ld+json"> { "@context": "https://schema.org/", "@id": "https://www.example.com/advancedCpp", "@type": "Course", "name": "Learn Advanced C++ Topics", "description": "Improve your C++ skills by learning advanced topics.", "publisher": { "@type": "Organization", "name": "CourseWebsite", "url": "https://www.examplecoursewebsite.com" }, "provider": { "@type": "Organization", "name": "Example University", "url": "https://www.example.com" } } </script> <?php } } add_action('wp_head', 'ava_json_ld_mod');
Make sure to the adjust the value of the is_page conditional function.
Best regards,
IsmaelAugust 8, 2025 at 12:42 am #1487727As always, thank you Ismael, you can make this as solved.
August 8, 2025 at 8:22 pm #1487754Hi,
Glad Ismael could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- The topic ‘Adding structured data to just 1 page’ is closed to new replies.