WordPress Integration
Learn how to integrate youraivoice.ai with your WordPress site to optimize your content for AI discovery.
Overview
WordPress powers over 40% of the web, and optimizing your WordPress site for AI visibility is crucial for staying competitive. There are three main approaches to integrate youraivoice.ai with WordPress:
Manual
Copy and paste generated code into your theme or posts
Plugin
Use a custom plugin to automate schema injection
API
Use our API to dynamically fetch and inject schema
Method 1: Manual Integration
The simplest way to add your generated schema to WordPress is manually through the theme editor or custom HTML blocks.
Step 1: Generate Your Schema
Create an entity in youraivoice.ai and generate the JSON-LD schema for your product, service, or content.
Step 2: Add to Theme Header
In WordPress admin, navigate to Appearance → Theme File Editor. Open your header.php file or use a child theme.
<!-- Add this before the closing </head> tag -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Product",
"name": "Your Product Name",
...
}
</script>Step 3: Or Use Custom HTML Block
When editing a post or page, add a Custom HTML block and paste your JSON-LD schema directly into it.
Method 2: Custom Plugin
For a more automated approach, create a simple WordPress plugin that injects your schema into specific pages or post types.
Sample Plugin Code
<?php
/*
Plugin Name: YourAIVoice Integration
Description: Adds JSON-LD schema to WordPress
Version: 1.0
*/
function youraivoice_add_schema() {
if (is_product()) {
$schema = array(
'@context' => 'https://schema.org',
'@type' => 'Product',
'name' => get_the_title(),
'description' => get_the_excerpt(),
// Add more fields as needed
);
echo '<script type="application/ld+json">';
echo json_encode($schema, JSON_UNESCAPED_SLASHES);
echo '</script>';
}
}
add_action('wp_head', 'youraivoice_add_schema');
?>Method 3: API Integration
Use our API to fetch schema dynamically and inject it into your WordPress pages. This is ideal for sites with many products or frequently changing content.
Step 1: Get Your API Key
Navigate to your account settings to generate an API key for programmatic access.
Step 2: Create API Integration
function youraivoice_fetch_schema($entity_id) {
$api_key = 'YOUR_API_KEY';
$url = "https://youraivoice.ai/api/entities/{$entity_id}/json-ld";
$response = wp_remote_get($url, array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key
)
));
if (is_wp_error($response)) {
return false;
}
return json_decode(wp_remote_retrieve_body($response));
}
function youraivoice_inject_schema() {
$entity_id = get_post_meta(get_the_ID(), 'entity_id', true);
if ($entity_id) {
$schema = youraivoice_fetch_schema($entity_id);
if ($schema) {
echo '<script type="application/ld+json">';
echo json_encode($schema);
echo '</script>';
}
}
}
add_action('wp_head', 'youraivoice_inject_schema');WordPress SEO Best Practices
- •Use a Child Theme: Always make modifications in a child theme to prevent updates from overwriting your changes
- •Cache Friendly: If using a caching plugin, ensure schema is cached along with your pages
- •Validate Schema: Use Google's Rich Results Test to validate your schema markup
- •One Schema Per Page: Avoid duplicate schema by ensuring only one version is injected per page
- •Mobile Optimization: Ensure your schema works correctly on mobile devices
Compatibility with Popular Plugins
Yoast SEO
youraivoice.ai schema works alongside Yoast. Disable Yoast's schema output for product pages if you're using ours.
WooCommerce
Integrate seamlessly with WooCommerce products by mapping product data to entity fields.
Elementor
Add schema using Custom HTML widgets or integrate with Elementor Pro's dynamic tags.
Advanced Custom Fields
Map ACF fields to entity properties for dynamic schema generation.
Ready to Optimize Your WordPress Site?
Start creating entities and integrating them with your WordPress site to improve your AI visibility.