Developer hooks and filters
Rilea SEO exposes filters for everything it prints: titles, descriptions, canonical URLs, robots directives, the schema graph and breadcrumbs. Here's each hook, what it receives and an example.
Rilea SEO docsVersion 1.1.04 min read
In short
- Add hooks in a child theme's
functions.phpor a small custom plugin, not in Rilea SEO's own files. - Output filters (
rilea_title,rilea_description,rilea_canonical,rilea_robots) change one tag each. rilea_resolvedchanges every SEO value for the current page at once, before anything is printed.rilea_schema_graphlets you add, change or remove any part of the JSON-LD graph.
Where to add hooks
Put your code in a child theme's functions.php, a site-specific plugin, or a code snippets plugin. Never edit Rilea SEO's files directly: updates replace them.
Every example below runs on the front end, after Rilea SEO has worked out the values for the current page.
Titles, descriptions and canonicals
rilea_title
Filters the final SEO title. Receives the title as a string.
add_filter( 'rilea_title', function ( $title ) {
if ( is_page( 'black-friday' ) ) {
$title = 'Black Friday Deals ' . gmdate( 'Y' ) . ' | Trailmark';
}
return $title;
} );rilea_description
Filters the meta description. Receives the description as a string. Return an empty string to print no description.
rilea_canonical
Filters the canonical URL. It's only printed when the page is indexable.
add_filter( 'rilea_canonical', function ( $url ) {
return is_paged() ? $url : strtok( $url, '?' );
} );rilea_robots
Filters the list of robots directives, such as index, follow and max-snippet:-1. Receives an array of strings; they're joined with commas.
add_filter( 'rilea_robots', function ( $robots ) {
if ( is_search() ) {
$robots = array( 'noindex', 'follow' );
}
return $robots;
} );All values at once
rilea_resolved
Rilea SEO works out every value for the current request once, then prints from it. This filter receives that array, with keys including title, desc, canonical, robots (an array with index and follow booleans), og_image, tw_image and post (the current post object or null). Change any value and return the array.
add_filter( 'rilea_resolved', function ( $r ) {
if ( $r['post'] && 'landing' === get_post_type( $r['post'] ) ) {
$r['robots']['index'] = false;
}
return $r;
} );Rilea SEO uses this filter itself to noindex hidden WooCommerce products.
Schema
rilea_schema_type
Filters the schema type for a post. Receives the type and the post object.
add_filter( 'rilea_schema_type', function ( $type, $post ) {
return 'recipe' === $post->post_type ? 'Recipe' : $type;
}, 10, 2 );rilea_schema_graph
Filters the whole graph before it's printed. Receives an array keyed by part: publisher, website, webpage, breadcrumb, primaryimage, author, entity, howto and video, depending on the page. Add your own key to add an entity, change a part, or unset one to remove it.
add_filter( 'rilea_schema_graph', function ( $graph ) {
if ( isset( $graph['publisher'] ) ) {
$graph['publisher']['foundingDate'] = '2019';
}
return $graph;
} );Rilea SEO uses this filter to add LocalBusiness schema on location pages.
Template variables
rilea_replace_var_{name}
Adds your own variable for title and description templates. Return a string to replace the variable, or null to leave it as it is. The second argument is the context, with post, term or user where available.
add_filter( 'rilea_replace_var_city', function ( $value, $ctx ) {
return ! empty( $ctx['post'] ) ? get_post_meta( $ctx['post']->ID, 'city', true ) : null;
}, 10, 2 );You can then use %city% in any template.
Breadcrumbs
rilea_breadcrumb_items
Filters the breadcrumb trail. Receives an array of items, each with a label and a url (empty for the current page).
add_filter( 'rilea_breadcrumb_items', function ( $items ) {
if ( is_singular( 'product' ) && count( $items ) > 1 ) {
$items[0]['label'] = 'Shop home';
}
return $items;
} );The same items are used for the visible trail and the BreadcrumbList schema, so they always match.
Post types and taxonomies
rilea_post_types and rilea_taxonomies
Filter which post types and taxonomies Rilea SEO manages: the settings, the editor panel and the sitemaps. Each receives an array of objects keyed by name. Unset a key to leave that type alone.
add_filter( 'rilea_post_types', function ( $types ) {
unset( $types['portfolio'] );
return $types;
} );Sitemaps
rilea_sitemap_allow_external_image
Image sitemaps include only images hosted on your own domain. Return true to include an image from another host, such as a CDN. Receives false and the image URL.
add_filter( 'rilea_sitemap_allow_external_image', function ( $allow, $src ) {
return $allow || 0 === strpos( $src, 'https://cdn.example.com/' );
}, 10, 2 );Table of contents
rilea_toc_source
Filters the content the table of contents reads headings from. Useful when a page builder stores headings outside the normal post content.
Admin
rilea_settings_tabs
Filters the tabs on the Settings screen, as an array of labels keyed by slug.
Actions
rilea_head
Runs inside Rilea SEO's section of the page head, after its meta tags. Rilea SEO prints the schema here. Hook in to print extra tags in the same place.
add_action( 'rilea_head', function () {
echo '<meta name="theme-color" content="#140A33" />' . "\n";
}, 30 );Template tag
rilea_breadcrumbs( $before, $after, $echo ) prints or returns the breadcrumb trail. See the shortcode and block reference.
Still stuck? Check the support FAQ or get in touch, and we'll help.
Get helpNext guides
Shortcode and block reference
Rilea SEO adds four editor blocks and seven shortcodes for FAQs, how-to steps, tables of contents, breadcrumbs and local business details.
Set up schema by content type
Rilea SEO builds a connected schema graph on every page.
Fix duplicate title, meta or schema tags
Every page should have exactly one title tag, one meta description, one canonical tag and one block of structured data.
Put your SEO budget somewhere else.
Install Rilea SEO, import your settings and keep every feature, for free.