Skip to content

Instantly share code, notes, and snippets.

View derweili's full-sized avatar

Julian Weiland derweili

  • Germany
  • 04:40 (UTC +02:00)
View GitHub Profile
@derweili
derweili / selena-add-author-child-functions.php
Created March 1, 2016 22:50
Code to add the author to the meta function of the sela wordpress theme. Answer for forum topic on wordpress.org https://wordpress.org/support/topic/meta_data-add-author-in-frontend?replies=1
if ( ! function_exists( 'sela_entry_meta' ) ) :
function sela_entry_meta() {
// Sticky
if ( is_sticky() && is_home() && ! is_paged() ) {
echo '<span class="featured-post">' . __( 'Featured', 'sela' ) . '</span>';
}
echo '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) . '">' . get_the_author() . '</a>';
@derweili
derweili / pregetposts_postnumber_filter.php
Last active May 11, 2016 08:34
Modify main query pased on taxonomy - wordpress
function derweili_change_postnumber_imagegallerycat( $query ) {
if ( $query->is_main_query() && $query->is_tax('bildergalerien-kategorie') ) {
$query->set('posts_per_page', 50);
return;
}
}
add_action( 'pre_get_posts', 'derweili_change_postnumber_imagegallerycat' );
@derweili
derweili / orbit-wp-gallery.php
Created September 5, 2016 15:13
WordPress Gallery based on Zurb Foundation Orbit Carousel
@derweili
derweili / brew.log
Created February 22, 2018 10:14
Brew Log
d
@derweili
derweili / wordpress-plugin-svn-to-git.md
Created March 2, 2018 14:23 — forked from kasparsd/wordpress-plugin-svn-to-git.md
Using Git with Subversion Mirroring for WordPress Plugin Development
@derweili
derweili / social-share.php
Created February 12, 2019 09:38
WordPress Social Share Link
<?php
function get_shared_base_url(){
if( is_single() || is_page() ){
return get_permalink( get_the_id() );
}else{
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
return $current_url;
}
@derweili
derweili / template-specific-editor-styles.js
Created February 17, 2020 10:55
Page Template specific editor styles for the WordPress Block Editor (Gutenberg)
const {
subscribe,
select
} = wp.data;
/**
* Add dark-mode class to block-editor based on selected page template
*/
wp.domReady( () => {
const postType = select( 'core/editor' ).getCurrentPostType();
@derweili
derweili / cdn-enabler-cachify-compatibility.php
Created June 8, 2021 14:01
Add Cachify compatibility to CDN Enabler
remove_action( 'setup_theme', array( 'CDN_Enabler_Engine', 'start' ) );
add_action( 'template_redirect', array( 'CDN_Enabler_Engine', 'start' ), 20 );
mkdir ~/bin
mkdir ~/bin/wp-cli
cd ~/bin/wp-cli
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
echo "export COLUMNS" >> ~/.bashrc
echo "alias wp='php ~/bin/wp-cli/wp-cli.phar'" >> ~/.bashrc
echo "alias php='/usr/bin/php'" >> ~/.bashrc
source ~/.bashrc
echo "PATH=$HOME/bin:$PATH" >> ~/.bashrc
@derweili
derweili / wp-share-a-draft-cpt-support.php
Last active January 28, 2022 09:51
WordPress Share a Draft Custom Post Type Support
<?php
/**
* Plugin Name: Share A Draft Helper
* Plugin URI: derweili.de
* Description: Add Custom Post Type Support to the Share A Draft Plugin
* Author: derweili
* Author URI: derweili.de
* Text Domain: share-a-draft-helper
* Domain Path: /languages
* Version: 0.1.0