Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / gist:3e635c45470a425b67341550507e9ad0
Created July 2, 2025 14:06 — forked from jdevalk/gist:0b2ddd13d27cf869a976
Change WP SEO JSON+LD search URL from ?s= to /search/
<?php
/**
* Changes the search slug to /search/ for the JSON+LD output
*/
function yst_change_json_ld_search_url() {
return trailingslashit( home_url() ) . 'search/{search_term}';
}
add_filter( 'wpseo_json_ld_search_url', 'yst_change_json_ld_search_url' );
@dexit
dexit / microdata-cpt.php
Created July 2, 2025 14:02 — forked from neilgee/microdata-cpt.php
Genesis Microdata Example - Changing a CPT SChema
add_action( 'get_header', 'themeprefix_cpt_microdata' );
//Change microdata for events custom post type
function themeprefix_cpt_microdata() {
if ('event' == get_post_type()) {//change to your cpt
//add in the microdata changes
add_filter( 'genesis_attr_entry', 'themeprefix_genesis_attributes_entry', 20 );

Schema.org, top snippets for your portfolio or blog with spatie/schema-org

@dexit
dexit / schema-org-functions.php
Created July 2, 2025 14:01 — forked from MaruscaGabriel/schema-org-functions.php
Genesis code for schema.org
<?php
// Remove the schema markup from an element
function mg_schema_empty( $attr ) {
$attr['itemtype'] = '';
$attr['itemprop'] = '';
$attr['itemscope'] = '';
return $attr;
}
@dexit
dexit / yoast_coauthors_integration.php
Created July 2, 2025 13:59 — forked from lubieowoce/yoast_coauthors_integration.php
Integrate Yoast with CoAuthors Plus
<?php
// Written against:
// - Yoast SEO 12.3
// - Co-Authors Plus 3.4
// - Wordpress 4.9.3
// - PHP 7.1
/*
@dexit
dexit / author-itemprop.php
Created July 2, 2025 13:58 — forked from jdevalk/author-itemprop.php
Bits of schema that require non-schema filters right now, for which I've written these functions
<?php
// For pages where you'd rather not have 20 rel=authors and in fact *do* need itemprop=author
// For instance on http://yoast.com/review/
function yoast_author_schema( $output ) {
return str_replace( 'rel="author"', 'itemprop="author"', $output );
}
add_filter( 'genesis_post_author_posts_link_shortcode', 'yoast_author_schema', 20 );
@dexit
dexit / archive-speaking_event.php
Created July 2, 2025 13:58 — forked from jdevalk/archive-speaking_event.php
Genesis helper code for schema
<?php
add_filter( 'genesis_attr_content', 'yoast_schema_empty', 20 );
add_filter( 'genesis_attr_entry', 'yoast_schema_event', 20 );
add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 );
add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 );
add_filter( 'genesis_post_title_output', 'yoast_title_link_schema', 20 );
/**
* We'll use the post info output to add more meta data about the event.
// create shortcode to list videos visually on video resource page with schema
add_shortcode( 'videos', 'videos_shortcode' );
function videos_shortcode( $atts ) {
ob_start();
extract( shortcode_atts( array (
'category' => '',
'quantity' => -1,
'p_id' => ''
), $atts ) );
@dexit
dexit / functions.php
Created July 2, 2025 13:57 — forked from bruceprock/functions.php
snippet in functions.php that needs content entry filter based on post-type/terms to apply product or review or creative schema entry-content all within the page
//Add Custom Micro Data To Specific Pages In Genesis using Yoast Genesis Schema Helper Script
add_filter( 'genesis_attr_body', 'custom_microdata_schema' );
function custom_microdata_schema( $attr ){
if( is_front_page() ){
add_filter( 'genesis_attr_entry', 'yoast_schema_product', 20 );
add_filter( 'genesis_attr_entry-title', 'yoast_itemprop_name', 20 );
add_filter( 'genesis_attr_entry-content', 'yoast_itemprop_description', 20 );
add_filter( 'genesis_post_title_output', 'yoast_title_link_schema', 20 );
}
<?php
/**
* Render the schema graph for the acf/gb-faq block.
*
* @param array $graph Schema data for the current page.
* @param WP_Block_Parser_Block $block The block data array.
* @param Meta_Tags_Context $context A value object with context variables.
*
* @return array Our Schema graph.
*/