Skip to content

Instantly share code, notes, and snippets.

View paaljoachim's full-sized avatar

Paal Joachim Romdahl paaljoachim

View GitHub Profile
@paaljoachim
paaljoachim / filed-under-categories
Last active February 13, 2016 15:45
Post preview and posts - Genesis code snippets
// Customize the post meta "FILED UNDER: -category name-" categories text and below the post preview in a blog page and change it at the bottom of a post.
// http://wordpress.stackexchange.com/questions/50961/removing-post-meta-from-category-pages */
//
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
if ( !is_page() ) {
if (is_archive() ) $post_meta = '';
else $post_meta = '[post_categories before="Categories: "] [post_tags before="Keywords: "]';
return $post_meta;
}}
@paaljoachim
paaljoachim / excerpt-tinymce.php
Last active February 13, 2016 15:52
TinyMCE Excerpt snippet. An easier way to show a more stylized excerpt.
/************************** https://github.com/cosmic/cosmic-tinymce-excerpt
* Plugin Name: Cosmic TinyMCE Excerpt
* Description: TinyMCE pour les extraits
* Author: Agence Cosmic
* Author URI: http://agencecosmic.com/
* Version: 1.0
****************************/
function cosmic_activate_page_excerpt() {
add_post_type_support('page', array('excerpt'));
//Altitude Pro customize.php code -
// Tutorial I am brushing up is here: http://easywebdesigntutorials.com/customizing-altitude-pro-genesis-child-theme/
<?php
/**
* Customizer additions.
*
* @package Altitude Pro
* @author StudioPress
* @link http://my.studiopress.com/themes/altitude/
@paaljoachim
paaljoachim / 1custom-post-type.php
Last active August 23, 2016 15:23
Custom Post Type - used in Minimum Pro Genesis Child Theme
//* Custom Post type code used inside the functions.php file inside the Minumum Pro Genesis child theme.
//* Create portfolio custom post type
add_action( 'init', 'minimum_portfolio_post_type' );
function minimum_portfolio_post_type() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio', 'minimum' ),
'singular_name' => __( 'Portfolio', 'minimum' ),
@paaljoachim
paaljoachim / functions.php
Created September 2, 2017 07:55
Add image to category screen.
// Made by Isaac: https://gist.github.com/itzikbenh/16326bc3947f272cd6bb44de03c4774b?fref=gc&dti=168889943173228
// and improved by Ian. https://www.facebook.com/groups/advancedwp/permalink/1607185879343620/
function add_category_meta_fields( $taxonomy ) {
?>
<div class="form-field create-cat term-featured-image-wrap">
<label for="tax-featured-image">Featured Image</label>
<input id="tax-featured-image" type="text" name="featured_image">
<br>
<button id="add-cat-featured-img" class="button" name="button">Add Featured Image</button>
@paaljoachim
paaljoachim / woocommerce-snippet.php
Last active January 10, 2018 08:16
WooCommerce checkout field adjustments. Removes company, country, address, city, state and postcode. I have commented out the removing of phone and e-mail. I have also removed the additional information box.
/* -------- WooCommerce - checkout fields ---------- */
/* From Kathy. */
function kia_modify_default_address_fields( $fields ){
if( isset( $fields['company'] ) ) unset( $fields['company'] );
if( isset( $fields['country'] ) ) unset( $fields['country'] );
if( isset( $fields['address_1'] ) ) unset( $fields['address_1'] );
if( isset( $fields['address_2'] ) ) unset( $fields['address_2'] );
if( isset( $fields['city'] ) ) unset( $fields['city'] );
if( isset( $fields['state'] ) ) unset( $fields['state'] );
@paaljoachim
paaljoachim / cpt.php
Last active September 10, 2018 15:53
Using the CPT - Custom Post Type UI plugin to create Custom Post Types
function cptui_register_my_cpts() {
/**
* Post Type: Nettmagasin.
*/
$labels = array(
"name" => __( "Nettmagasin", "tm-beans" ),
"singular_name" => __( "Nettmagasin", "tm-beans" ),
"all_items" => __( "Alle Nettmag tekster", "tm-beans" ),
@paaljoachim
paaljoachim / featured-images.php
Last active September 12, 2018 10:44
Set Featured image. 1. Sets the featured image. 2. If no featured image get image from category. 3. If no category image then get the first post image. 4. If no post image or category image then sets a fallback image.
@paaljoachim
paaljoachim / hide-meta-boxes-single-post-page-screen.php
Last active October 14, 2018 08:33
Hide meta boxes in the single page and post screen. Turn them on again in the Screen Options. Add the code to your WordPress child theme functions file or a custom functions plugin.
// At http://wordpress.stackexchange.com/questions/15376/how-to-set-default-screen-options bottom comment the following code $hidden is mentioned.
// Hides meta boxes. Turn them on through the Screen Options.
add_filter( 'hidden_meta_boxes', 'custom_hidden_meta_boxes' );
function custom_hidden_meta_boxes( $hidden ) {
// Hide meta boxes on the single Post screen
// Left column
$hidden[] = 'postexcerpt'; // Post Excerpts
$hidden[] = 'trackbacksdiv'; // Send Trackbacks
$hidden[] = 'postcustom'; // Custom Fields
$hidden[] = 'commentstatusdiv'; // Discussion
@paaljoachim
paaljoachim / 1functions.php
Last active January 21, 2019 00:26
Custom Post Type - used in Executive Pro Genesis Child Theme
//* Custom Post type code used inside the functions.php file inside the Executive Pro Genesis child theme.
//* Create Portfolio Type custom taxonomy
add_action( 'init', 'executive_type_taxonomy' );
function executive_type_taxonomy() {
register_taxonomy( 'portfolio-type', 'portfolio',
array(
'labels' => array(
'name' => _x( 'Types', 'taxonomy general name', 'executive' ),
'add_new_item' => __( 'Add New Portfolio Type', 'executive' ),