Skip to content

Instantly share code, notes, and snippets.

//Display short blog title in WordPress
//There is a simple script you can use to implement a short blog title without modifying the base WordPresscode. Open up your functions.php file within your theme and add the following:
function short_title() {
$title = get_the_title();
$count = strlen($title);
if ($count >= 25) {
$title = substr($title, 0, 25);
1/ Go to WP Repository and search for WP Smush
2/ Install WP Smush to Your WP Site
3/ Go to WP Smush plugin installation folder
4/ Go to “lib” folder
5/ Open file “class-wp-smush.php” for editing
6/ Search for “if ( empty( $api_key ) )”
7/ This function returns false, so change to true.
<?php
if(ICL_LANGUAGE_CODE=='en'){
echo 'content in english';
}
if(ICL_LANGUAGE_CODE=='es'){
echo 'content in spanish';
}
?>
// USAGE
<?php the_title( $before, $after, $echo ); ?>
/* $before
(string) Text to place before the title. Defaults to ''.
$after
(string) Text to place after the title. Defaults to ''.
$echo
(Boolean) Display the title (true) or return it for use in PHP (false). Defaults to true.
*/
/*
Quick Tip! What happens when your post title does not fit on one line? It wraps to the second line. What if it’s only one word? And what if that word is “it” or some other shorty? Your title won’t look too nice, eh? Here’s a solution, somewhere inside the loop:
*/
$title = the_title( '<h2>', '</h2>', false );
if ( strlen( $title ) > 0 )
echo substr_replace( $title, '&nbsp;', strrpos( $title, ' ' ), 1 );
<?php
/**
* Block template file: template-parts/blocks/sidebar/sidebar-headline.php
*
* Sidebar Headline Block Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
//********************************************************************************
// Change text size of Gutenberg editor
// https://studiopress.blog/block-font-sizes/
//********************************************************************************
// Adds support for editor font sizes.
// Do NOT include the opening php tag.
add_theme_support( 'editor-font-sizes', array(
array(
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'Your-Custom-Field', true);
wp_reset_query();
.arrow-up {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid black;
}
.arrow-down {