Skip to content

Instantly share code, notes, and snippets.

🏁
Getting back into self-employment

Silvan Hagen neverything

🏁
Getting back into self-employment
Block or report user

Report or block neverything

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
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]
View wp-cli-posts-by-language-polylang.sh
# Assuming you have polylang for translations, get the language you want to query:
wp term list language
# Use the language term slug for and --language as it's the taxonomy:
wp post list --post_type=post,page --lang=de --format=ids
# Pipe them so they are comma seperated
wp post list --post_type=post,page --lang=de --format=ids | tr " " ","
@neverything
neverything / .htaccess
Created Jan 8, 2019 — forked from HechtMediaArts/.htaccess
UPDATE 2019: Perfect .htaccess file for highspeed and security. You can use it for every WordPress-Website without problems. Highspeed and Security - testet on hundreds of Websites. If you are using a WordPress Multisite, change the last part of this file.
View .htaccess
########################################################################
# OPTIMAL .htaccess FILE FOR SPEED AND SECURITY @Version 2019
# ----------------------------------------------------------------------
# @Author: Andreas Hecht
# @Author URI: https://andreas-hecht.com
# License: GNU General Public License v2 or later
# License URI: http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
@neverything
neverything / sql-replace-encoding-errors.sql
Created Dec 12, 2018
With these commands you can search and replace encoding issues. Additional chars can be found here https://www.i18nqa.com/debug/utf8-debug.html
View sql-replace-encoding-errors.sql
UPDATE wp_posts SET post_content = REPLACE(post_content, unhex('C383C2A0'), 'à') WHERE post_type='post';
UPDATE wp_posts SET post_title = REPLACE(post_title, unhex('C383C2A0'), 'à') WHERE post_type='post';
@neverything
neverything / equalize-list-style.css
Created Jul 12, 2018
Generatepress CSS snippets
View equalize-list-style.css
.entry-content ul > li,
.page-description ul > li,
.term-description ul > li,
.taxonomy-description ul > li,
.entry-content ol > li,
.page-description ol > li,
.term-description ol > li,
.taxonomy-description ol > li,
.generate-sections-inside-container ul > li,
.generate-sections-inside-container ol > li {
View wp-cli-change-post-author.sh
# For pages
wp post update $(wp post list --format=ids --post_type=page) --post_author=6
# For posts
wp post update $(wp post list --format=ids) --post_author=6
You can’t perform that action at this time.