PHP code example of tag1 / scolta-wp
1. Go to this page and download the library: Download tag1/scolta-wp library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tag1 / scolta-wp example snippets
// In your theme's functions.php or a plugin
register_post_type('recipe', [
'label' => 'Recipes',
'public' => true,
'has_archive' => true,
'supports' => ['title', 'editor', 'custom-fields'],
]);
add_filter('scolta_content_item', function ($item, $post) {
if ($post->post_type !== 'recipe') {
return $item;
}
$cuisine = get_post_meta($post->ID, '_recipe_cuisine', true);
$diet = get_post_meta($post->ID, '_recipe_diet', true);
return new \Tag1\Scolta\Export\ContentItem(
id: $item->id,
title: $item->title,
bodyHtml: $item->bodyHtml
. '<p>Cuisine: ' . esc_html($cuisine) . '</p>'
. '<p>Diet: ' . esc_html($diet) . '</p>',
url: $item->url,
date: $item->date,
siteName: $item->siteName,
);
}, 10, 2);
define('SCOLTA_API_KEY', 'sk-ant-...');
$settings = get_option('scolta_settings', []);
$settings['ai_model'] = 'claude-opus-4-6';
$settings['ai_languages'] = ['en', 'fr', 'de'];
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['recency_boost_max'] = 0.8;
$settings['recency_half_life_days'] = 30;
$settings['recency_penalty_after_days'] = 365;
$settings['recency_max_penalty'] = 0.5;
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['recency_strategy'] = 'none';
$settings['title_match_boost'] = 2.0;
$settings['title_all_terms_multiplier'] = 2.5;
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['recency_strategy'] = 'none';
$settings['title_match_boost'] = 1.5;
$settings['title_all_terms_multiplier'] = 2.0;
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['sayt_enabled'] = false;
update_option('scolta_settings', $settings);
add_filter('scolta_prompt', function (string $prompt, string $promptName, array $context): string {
if ($promptName === 'summarize') {
$prompt .= "\n\nFocus on cuisine type and dietary information.";
}
return $prompt;
}, 10, 3);
$settings = get_option('scolta_settings', []);
$settings['ai_summary_top_n'] = 15;
$settings['ai_summary_max_chars'] = 6000;
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['ai_languages'] = ['de']; // or ['en', 'fr', 'de'] for multilingual
update_option('scolta_settings', $settings);
$settings = get_option('scolta_settings', []);
$settings['expand_primary_weight'] = 0.8; // closer to 1.0 = original query dominates
// or: $settings['ai_expand_query'] = false;
update_option('scolta_settings', $settings);
add_filter('scolta_content_item', function ($item, $post) {
// Use do_blocks() instead of apply_filters('the_content'):
// renders Gutenberg blocks but skips Yoast, WooCommerce, etc.
return new \Tag1\Scolta\Export\ContentItem(
id: $item->id,
title: $item->title,
bodyHtml: do_blocks($post->post_content),
url: $item->url,
date: $item->date,
siteName: $item->siteName,
);
}, 10, 2);
add_filter('scolta_content_item', function ($item, $post) {
$extra = get_field('product_specs', $post->ID);
if ($extra) {
$item = new \Tag1\Scolta\Export\ContentItem(
id: $item->id,
title: $item->title,
bodyHtml: $item->bodyHtml . '<p>' . esc_html($extra) . '</p>',
url: $item->url,
date: $item->date,
siteName: $item->siteName,
);
}
return $item;
}, 10, 2);
add_action( 'scolta_scheduled_rebuild', function () {
if ( class_exists( 'Scolta_Rebuild_Scheduler' ) ) {
Scolta_Rebuild_Scheduler::start_rebuild();
}
} );
bash
cd test-wordpress-7
ddev wp eval-file tests/integration-test.php