Skip to content

Instantly share code, notes, and snippets.

View Netzberufler's full-sized avatar

Thomas Weichselbaumer Netzberufler

View GitHub Profile
@Netzberufler
Netzberufler / content-portfolio.php
Created May 4, 2017 10:33
Portfolio Template using Static Child Pages
<?php
/**
* The template used for displaying portfolio items.
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<a href="<?php the_permalink(); ?>" rel="bookmark">
<?php the_post_thumbnail( 'medium' ); ?>
@Netzberufler
Netzberufler / wp-plugin-boilerplate.php
Created October 19, 2016 12:35
WordPress Plugin Boilerplate
<?php
/*
Plugin Name: Plugin Boilerplate
Plugin URI: https://themecoder.de/
Description: My boilerplate for WordPress Plugins
Author: Thomas Weichselbaumer
Author URI: http://netzberufler.de
Version: 1.0
Text Domain: plugin-boilerplate
Domain Path: /languages/
@Netzberufler
Netzberufler / archive.php
Created November 10, 2016 16:24
Grid Layout mit Flexbox: WordPress Loop
<?php
/**
* The template for displaying archive pages
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
@Netzberufler
Netzberufler / functions.php
Created November 7, 2016 16:29
Shortcode to display WordPress Menu
<?php
/**
* Shortcode to display a WordPress menu
*
*/
function theme_slug_menu_shortcode( $atts ) {
// Get Shortcode Parameters.
$menu = shortcode_atts( array(
'slug' => '',
@Netzberufler
Netzberufler / functions-2.php
Last active October 4, 2016 13:38
WordPress Core Archive Title Function
<?php
/**
* Filter the default archive title.
*
* @param string $title Archive title.
* @return string $title
*/
function theme_slug_archive_title( $title ) {
if ( is_category() ) {
@Netzberufler
Netzberufler / customizer.php
Last active September 23, 2016 08:42
Sanitization callback for select and radio type Customizer controls.
<?php
/**
* Sanitization callback for 'select' and 'radio' type controls.
*
* @copyright Copyright (c) 2015, WordPress Theme Review Team, https://github.com/WPTRT/code-examples
* @see sanitize_key() https://developer.wordpress.org/reference/functions/sanitize_key/
* @see $wp_customize->get_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/get_control/
*
* @param String $input Slug to sanitize.
* @param WP_Customize_Setting $setting Setting instance.
@Netzberufler
Netzberufler / functions.php
Created September 19, 2016 13:03
Font Size von Tag Cloud Widget ändern
<?php
/**
* Modifies tag cloud widget arguments to have all tags in the widget same font size.
*
* @param array $args Arguments for tag cloud widget.
* @return array A new modified arguments.
*/
function themeslug_widget_tag_cloud_args( $args ) {
$args['largest'] = 0.8125;
$args['smallest'] = 0.8125;
@Netzberufler
Netzberufler / functions.php
Created September 19, 2016 12:32
Read More Button nach Excerpt einfügen
<?php
/**
* Add Read More button to excerpts
*
* @param string $more_text Excerpt More Text.
* @return string
*/
function themeslug_excerpt_more( $more_text ) {
return '<a href="' . esc_url( get_permalink() ) . '" class="more-link">' . esc_html__( 'Continue reading', 'themeslug' ) . '</a>';
@Netzberufler
Netzberufler / category-dropdown-control.php
Last active September 17, 2016 14:18
Category Dropdown Control
/**
* Make sure that custom controls are only defined in the Customizer
*/
if ( class_exists( 'WP_Customize_Control' ) ) :
/**
* A custom category dropdown control for the Customizer
*/
class Theme_Slug_Category_Dropdown_Control extends WP_Customize_Control {
/**
@Netzberufler
Netzberufler / functions.php
Last active September 10, 2016 13:46
Social Icons Menu
<?php
/**
* Sets up theme defaults and registers support for various WordPress features.
*/
function theme_slug_setup() {
// Register Social Icons Menu.
register_nav_menu( 'social', esc_html__( 'Social Icons', 'theme-slug' ) );
}