Category: Archive
Untitled Snippet
Shortcode for the Site Title [site-title]
// Shortcode for the site title function site_title_shortcode() { $name = get_bloginfo(‘name’); return $name; } add_shortcode(‘site-title’, ‘site_title_shortcode’);Continue reading
Shortcode for Current Year [year]
// Shortcode for current year function year_shortcode() { $year = date_i18n(‘Y’); return $year; } add_shortcode(‘year’, ‘year_shortcode’);Continue reading
Post class update
add_filter( ‘body_class’, function( $classes ) { $acc_type=tmwp_get_user_role(); if (!$acc_type) $acc_type=’anonymous’; return array_merge( $classes, array(‘acc-type-‘.strtolower($acc_type),tmwp_get_page_class()) ); } );Continue reading
Simple Table Of Contents (copy)
add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading
Simple Table Of Contents
add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading
Open External Links in a New Tab
add_filter( ‘the_content’, function ( $content ) { // This snippet requires the DOMDocument class to be available. if ( ! class_exists( ‘DOMDocument’ ) ) { return $content; } if ( !is_single() || !in_the_loop() || !is_main_query() ) { return $content; }…Continue reading
Disable Dynamic Template on the Homepage/Front-page
add_filter( ‘totaltheme/theme_builder/location_template_id’, function( $template_id, $location ) { if ( $template_id && ‘single’ === $location && is_front_page() ) { $template_id = 0; // disable on the homepage } return $template_id; }, 10, 2 );Continue reading