Skip to content

Instantly share code, notes, and snippets.

Avatar

Jochen Gererstorfer gmmedia

View GitHub Profile
@gmmedia
gmmedia / functions.php
Created Jun 29, 2021
Add alt tag to WordPress Gravatar images
View functions.php
// Add alt tag to WordPress Gravatar images
// Full how-to: https://bloggerpilot.com/gravatar-alt-tag/
function bloggerpilot_gravatar_alt($bloggerpilotGravatar) {
if (have_comments()) {
$alt = get_comment_author();
}
else {
$alt = get_the_author_meta('display_name');
}
$bloggerpilotGravatar = str_replace('alt=\'\'', 'alt=\'Avatar für ' . $alt . '\'', $bloggerpilotGravatar);
@gmmedia
gmmedia / page-something.php
Last active Oct 8, 2021
Kadence page template with the_content
View page-something.php
<?php
/**
* Template Name: something
*
* @package kadence
*/
namespace Kadence;
@gmmedia
gmmedia / page-tools.php
Last active Jun 22, 2021
Kadence page template wp_footer
View page-tools.php
<?php
/**
* Template Name: Tools
*
* @package kadence
*/
namespace Kadence;
@gmmedia
gmmedia / functions.php
Last active Oct 6, 2021
WordPress: Remove unwonted image sizes, like medium_large, 1536x1536, 2048x2048
View functions.php
/*
* WordPress: Remove unwonted image sizes.
* In this code I remove the three sizes medium_large, 1536x1536, 2048x2048
* See full article:
*/
add_filter('intermediate_image_sizes', function($sizes) {
return array_diff($sizes, ['medium_large']); // Medium Large (768 x 0)
});
@gmmedia
gmmedia / gist:b895225d3eefb42bdfc573836b776b86
Last active May 12, 2021
Enable Gutenberg editor for WooCommerce
View gist:b895225d3eefb42bdfc573836b776b86
// Enable Gutenberg editor for WooCommerce
function j0e_activate_gutenberg_product( $can_edit, $post_type ) {
if ( $post_type == 'product' ) {
$can_edit = true;
}
return $can_edit;
}
add_filter( 'use_block_editor_for_post_type', 'j0e_activate_gutenberg_product', 10, 2 );
// Enable taxonomy fields for Woocommerce with Gutenberg on
@gmmedia
gmmedia / functions.php
Last active Mar 24, 2021
WordPress: Wiederverwendbaren Block erstellen
View functions.php
function j0e_register_block_patterns() {
if ( class_exists( 'WP_Block_Patterns_Registry' ) ) {
register_block_pattern(
'j0e-header-pattern',
array(
'title' => __( 'Überschrift', 'j0e-patterns' ),
'description' => _x( 'Hier steht die Beschreibung des Pattern', 'Block pattern description', 'j0e-patterns' ),
'categories' => array('hero'),
@gmmedia
gmmedia / functions.pnp
Last active Aug 31, 2021
Add featured image column to WP admin panel - posts AND pages
View functions.pnp
/**
* Add featured image column to WP admin panel - posts AND pages
* See: https://j0e.org/featured-image-admin/
*/
// Set thumbnail size
add_image_size( 'j0e_admin-featured-image', 60, 60, false );
// Add the posts and pages columns filter. Same function for both.
add_filter('manage_posts_columns', 'j0e_add_thumbnail_column', 2);
@gmmedia
gmmedia / functions.php
Last active Mar 2, 2021
Astra Theme: Display last modified and publisheddate in the post metadata.
View functions.php
/**
* Astra Theme: Display last modified and published date in the post metadata.
* See: https://j0e.org/astra-tipps-tricks/
*/
function j0e_post_date( $output ) {
$output = '';
$format = apply_filters( 'astra_post_date_format', '' );
$published_date = esc_html( get_the_date( $format ) );
$published_on = sprintf(
esc_html( '%s' ),
@gmmedia
gmmedia / Custom Post Type Landingpage
Last active Oct 8, 2021
Landingpage Abschnitt in WordPress
View Custom Post Type Landingpage
/**
* Custom Post Type: Landingpages.
* Add to your functions.php
*/
function cptui_register_my_cpts_landingpage() {
/**
* Post Type: Landingpages.
*/
@gmmedia
gmmedia / German Stopwords - Deutsche Stop Wörter
Created Feb 11, 2021
Stop Wörter für SEO und Crawling
View German Stopwords - Deutsche Stop Wörter
ab
aber
abermaliges
abermals
abgerufen
abgerufene
abgerufener
abgerufenes
abgesehen
acht