Skip to content

Instantly share code, notes, and snippets.

Avatar

WordPress-Handbuch WordPress-Handbuch

View GitHub Profile
View gist:777e49797faf05e4f129e492ff70ca59
function wordpress_handbuch_shortcode( ) {
return '<a href="https://wordpress-handbuch.com">WordPress-Handbuch.com</a>';
}
add_shortcode( 'wphb', 'wordpress_handbuch_shortcode' );
@WordPress-Handbuch
WordPress-Handbuch / listing-18-1.php
Created Dec 14, 2018
WordPress 5 Plugin: WH_Hello_World
View listing-18-1.php
<?php
/**
* @package WH_Hello_World
* @version 1.0.0
*/
/*
Plugin Name: WH Hello World
Plugin URI: https://wordpress-handbuch.com
Description: Testausgabe in Front- und Backend
Author: Richard Eisenmenger
@WordPress-Handbuch
WordPress-Handbuch / listing-6-4.php
Last active Jan 16, 2019
WordPress 5/Gutenberg: Disable all color options in blocks
View listing-6-4.php
/**
* Disable all color options in Gutenberg
*/
function my_theme_and_gutenberg_adjustments() {
add_theme_support( 'editor-color-palette' );
add_theme_support( 'disable-custom-colors' );
}
add_action( 'after_setup_theme', 'my_theme_and_gutenberg_adjustments' );
@WordPress-Handbuch
WordPress-Handbuch / listing-19-1.php
Last active Feb 18, 2020
WordPress 5 – Register new post type in an own plugin
View listing-19-1.php
<?php
/**
* Plugin Name: WH Custom Post Type
*/
function add_wh_events() {
$labels = array(
'name' => 'Veranstaltungen',
'singular_name' => 'Veranstaltung',
'add_new' => 'Erstellen',
'add_new_item' => 'Neue Veranstaltung erzeugen',
@WordPress-Handbuch
WordPress-Handbuch / listing-6-1.php
Last active Jan 16, 2019
Code fragment for ribbon include example
View listing-6-1.php
<?php if (get_post_meta(get_the_ID(), 'Ribbon', true) != '') { ?>
<div class="ribbon ribbon-top-right">
<span><?php echo (get_post_meta(get_the_ID(), 'Ribbon', true)); ?></span>
</div>
<?php } ?>
@WordPress-Handbuch
WordPress-Handbuch / listing-6-2.css
Last active Dec 4, 2020
Code fragment for ribbon include example – CSS part
View listing-6-2.css
.ribbon {
width: 150px;
height: 150px;
overflow: hidden;
position: absolute;
z-index:9;
}
.ribbon span {
position: absolute;
@WordPress-Handbuch
WordPress-Handbuch / listing-6-3.php
Last active Jan 16, 2019
WordPress 5/Gutenberg: Activate only specific block types
View listing-6-3.php
/**
* Allow only certain block types in Gutenberg
* Possible:
* core/list, core/quote, core/cover-image, core/paragraph, core/image, core/heading, core/gallery, core/audio, core/file, core/video
* core/freeform, core/html, core/code, core/preformatted, core/pullquote, core/table, core/verse
* core/button, core/text-columns, core/more, core/nextpage, core/separator, core/spacer
* core/shortcode, core/archives, core/categories, core/latest-comments, core/latest-posts
* core-embed/: twitter, youtube, facebook, Instagram, wordpress, soundcloud, spotify, flickr, vimeo, animoto, cloudup, collegehumor, dailymotion, funnyordie, hulu, imgur, issuu, kickstarter, meetup-com, mixcloud, photobucket, polldaddy, reddit, reverbnation, screencast, sribd, slideshare, smugmug, speaker, ted, tumblr, videopress, wordpress-tv
*/
function my_allowed_block_types( $allowed_blocks ) {
@WordPress-Handbuch
WordPress-Handbuch / listing-10-1.html
Last active Jan 30, 2019
HTML meta tags for proper social media share integration
View listing-10-1.html
<meta name="description" content="Auszug/Exzerpt" />
<meta name="twitter:site" content="Website-Titel" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="Webseiten-Titel" />
<meta name="twitter:description" content="Auszug/Exzerpt" />
<meta name="twitter:image" content="Vorschaubild" />
<meta name="twitter:url" content="Permalink-URL" />
<meta property="og:site_name" content="Website-Titel" />
<meta property="og:title" content="Webseiten-Titel" />
<meta property="og:description" content="Auszug/Exzerpt" />
@WordPress-Handbuch
WordPress-Handbuch / listing-10-2.php
Last active Sep 4, 2019
PHP/HTML blog snippet for proper WordPress HTML meta tag integration for social network sharing
View listing-10-2.php
<?php
if (is_single())
{
$title = htmlspecialchars( strip_tags( get_the_title( $post->ID ) ) );
$description = htmlspecialchars( strip_tags( get_the_excerpt( $post->ID ) ) );
$thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
$image = $thumbnail[0];
$type = 'article';
} elseif (is_page()) {
$title = htmlspecialchars( strip_tags( get_the_title( $post->ID ) ) );
@WordPress-Handbuch
WordPress-Handbuch / listing-10-3.php
Created Jan 30, 2019
PHP code for inserting Previous/Next post links at the end of a WordPress post
View listing-10-3.php
the_post_navigation(
array(
'next_text' => '<span class="meta-nav" aria-hidden="true">Weiter</span> ' .
'<span class="screen-reader-text">Weiter</span> <br/>' .
'<span class="post-title">%title</span>',
'prev_text' => '<span class="meta-nav" aria-hidden="true">Zurück</span> ' .
'<span class="screen-reader-text">Zurück</span> <br/>' .
'<span class="post-title">%title</span>',
)
);