Skip to content

Instantly share code, notes, and snippets.

Avatar
🍌
Hasn't played Mario Kart in a while

Silvan Hagen neverything

🍌
Hasn't played Mario Kart in a while
View GitHub Profile
View shortcode-render-tax-terms.php
<?php
/**
* Shortcode: [pp_tax_list] to render an unlinked list of taxonomy terms assigned
* to the current object.
*
* How to use: [pp_tax_list tax='<taxonomy>']
* Optional params are:
* display='list|string' defaults to list
* wrapper_class='pp-tax-list' any css classes that are needed on the wrapper div.
*
View generate_press_social_sharing_after_post_meta.php
<?php
add_filter( 'generate_post_author_output', function( $output ) {
if ( is_singular( 'post' ) ) {
$current_id = get_the_ID();
$social_links = [];
// Add opening div
$social_links[] = '<div class="social-sharing">';
// Intro Text
$social_links[] = '<span>Artikel teilen: </span>';
View wp-oembed-disable-dnt.php
<?php
/**
* Remove Do Not Track Attribute from URLs of embeds like Videos.
*
* @param string $provider oembed Provider
* @param string $url embed url
* @param array $args embed args
*
* @return string $url with custom add-ons.
*/
View ld-hide-progress.css
.logged-in .ld-progress {
display: none;
}
/* .ld-progress might hase to be changed, depending on your theme */
@neverything
neverything / rankmath-faq-accordion.css
Last active Dec 18, 2020
RankMath SEO: FAQ block with collapsible headers aka an accordion, see full blog post: https://silvanhagen.com/?p=1125
View rankmath-faq-accordion.css
#rank-math-faq .rank-math-list-item {
margin-bottom: 1em;
margin-top: 1em;
border-bottom: 1px solid #fff;
}
.rank-math-question {
cursor: pointer;
position: relative;
display: block;
View functions-snippet-hide-cpt-search.php
<?php
/**
* Hide CPT from Search
*/
function update_my_custom_type() {
global $wp_post_types;
if ( post_type_exists( 'wpm-testimonail' ) ) {
View schema-site-navigation-element.js
<script type="application/ld+json">{
"@context":"https:\/\/schema.org",
"@graph":[
{
"@context":"https:\/\/schema.org",
"@type":"SiteNavigationElement",
"id":"site-navigation",
"name":"WordPress",
"url":"https:\/\/silvanhagen.com\/wordpress\/"
},
View render-reusable-block.php
<?php
/**
* Renders content before the blog starts. Using a reusable gutenberg block.
*/
function generate_blog_intro() {
/**
* Make sure we are on the posts page.
*/
if ( is_home() ) {
/**
@neverything
neverything / functions.php
Created Feb 14, 2019
Add a custom logout link to the main menu for logged in users
View functions.php
<?php
function wti_loginout_menu_link( $items, $args ) {
if ($args->theme_location == 'primary') { // Adjust this to the menu location.
if (is_user_logged_in()) {
$items .= '<li class="right"><a href="'. wp_logout_url() .'">'. __("Log Out", "textdomain") .'</a></li>';
}
}
return $items;
}
@neverything
neverything / .htaccess
Created Jan 22, 2019 — forked from trongcong/.htaccess
Wordpress login to download uploaded files | Protect uploaded files with login | Edit by trongcong
View .htaccess
RewriteCond %{REQUEST_FILENAME} -s
RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L]