Skip to content

Instantly share code, notes, and snippets.

View gmmedia's full-sized avatar

Jochen Gererstorfer gmmedia

View GitHub Profile
@gmmedia
gmmedia / functions.php
Last active August 13, 2023 14:18
Shortcode: CategoryPosts - Content Hub
<?php
// WordPress Shortcode - Content Hub: Lists all posts for the first category of a post
// Need help: https://bloggerpilot.com/en/content-hub-wordpress/
function bp_categoryposts() {
// Get first category
$categories = get_the_category();
if ( ! empty( $categories ) ) {
@gmmedia
gmmedia / style.css
Created June 23, 2023 13:51
Kadence Blocks Row Layout - Make CTA buttons correctly aligned on the bottom of each content box container despite each box having different lengths of text
/* https://startblogging101.com/kadence-blocks-content-boxes/ */
selector .wp-block-kadence-column .kt-inside-inner-col {
display: flex;
flex-direction: column;
flex: 1;
}
selector .wp-block-kadence-column .kt-inside-inner-col .wp-block-kadence-advancedbtn {
margin-top: auto;
@gmmedia
gmmedia / single.php
Created May 8, 2023 19:54
Aktualisierungsdatum in Farbe
echo '<span style="color: #99000;">Artikel aktualisiert am ' . get_the_modified_date('d.m.Y') . '<span>';
@gmmedia
gmmedia / .htaccess
Created April 26, 2023 12:17
WordPress: Force add trailing slash
# Force trailing slash
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_METHOD} GET
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !^/wp-json/
RewriteCond %{REQUEST_URI} !^/gravatars/
RewriteCond %{REQUEST_FILENAME} !\.(gif|jpg|png|jpeg|css|xml|txt|js|php|scss|webp|mp3|avi|wav|mp4|mov|pdf|html|htm|xst)$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]
@gmmedia
gmmedia / functions.php
Created February 22, 2023 10:54
Add a Logo to the WordPress Login
<?php
// Add a Logo to the WordPress Login
add_action('login_head', 'bloggerpilot_loginlogo');
function bloggerpilot_loginlogo() {
echo '<style type="text/css">
h1 a {
background-image: url(https://bloggerpilot.com/wp-content/uploads/2021/06/logo.svg) !important;
width: 200px !important;
height: 42px !important;
@gmmedia
gmmedia / functions.php
Last active February 6, 2023 14:09
FluentForms - Email Blacklist - Specific Forms
<?php
// FluentForms - Email Blacklist - Specific Forms
// Need help: https://bloggerpilot.com/snippet-fluentforms-e-mail-blacklist/
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
The ID(s) of the form
$targetFormId = [13,14];
@gmmedia
gmmedia / functions.php
Created January 16, 2023 11:09
WordPress: Add Script to Header in first position/priority
add_action( 'wp_head', function () { ?>
<script></script>
<?php }, -1000 );
@gmmedia
gmmedia / functions.php
Created January 16, 2023 11:08
WordPress Hook: Truendo
add_action( 'wp_head', function () { ?>
<!-- TRUENDO Privacy Center --><script async="" id="truendoAutoBlock" type="text/javascript" src="https://cdn.priv.center/pc/truendo_cmp.pid.js" data-siteid="3dce3136-5f8d-4c4a-b418-cc414d098a34"></script><!-- End TRUENDO Privacy Center -->
<?php }, -1000 );
@gmmedia
gmmedia / functions.php
Last active February 6, 2023 12:56
FluentForms - E-Mail Blacklist - All Forms
<?php
// FluentForms - E-Mail Blacklist
// Need help: https://bloggerpilot.com/en/snippet-fluentforms-email-blacklist/
add_filter('fluentform_validate_input_item_input_email', function ($error, $field, $formData, $fields, $form) {
// These listed domains will fail to submit the form
$blacklistDomains = ['gmail.com', 'hotmail.com', 'test.com'];
@gmmedia
gmmedia / functions.php
Last active December 21, 2022 06:49
Display hidden WordPress plugin and theme update notifications on the update-core screen.
<?php
/**
* Debug Pending Updates
*
* Displays hidden plugin and theme updates on update-core screen.
* Source: https://stackoverflow.com/a/52132227
*/
function debug_pending_updates() {