Skip to content

Instantly share code, notes, and snippets.

@SiGaCode
SiGaCode / read_more_customizer.php
Created June 5, 2015 12:43
Adds "Read more" to WP customizer. Code goes in CUSTOM FUNCTIONS in Dynamik - Dont forget to check the box "Affect Admin". Credits: Junior Atoms. http://cobaltapps.com/forum/forum/main-category/web-design-talk/42707-how-do-i-get-the-read-more-button-to-show-up?p=67578#post67578
//* Add read more to customize -code by junior atoms
add_action( 'customize_register', 'jr_register_read_more_customize' );
function jr_register_read_more_customize( $wp_customize ) {
$wp_customize->add_section(
'jr_read_more_section',
array(
'title' => 'Read More',
'priority' => 200
)
@SiGaCode
SiGaCode / numbered-list.css
Created June 7, 2015 17:04
Nice numbered list, numbers with text-shadow in colored circles. Credits: http://blog.teamtreehouse.com/customize-ordered-lists-pseudo-element
ol.numbers {
list-style-type: none !important;
margin: 0;
padding: 0;
}
ol.numbers li {
counter-increment: step-counter;
font-size: 18px;
list-style-type: none !important;
margin: 0 0 12px;
@SiGaCode
SiGaCode / move_titles_styles.css
Last active January 9, 2017 11:22
Moves titles above content and sidebar and adds a custom CSS class to style them without affecting those who weren´t moved. Credits to: https://gist.github.com/SmartWizardSolutions/8468002 and: https://gist.github.com/salcode/7164690
h1.entry-title.above {
text-align:center;
background:#000000;
color:#fff;
padding: 15px 0;
}
@SiGaCode
SiGaCode / custom_contact_sidebar.php
Last active August 29, 2015 14:26
Create a custom sidebar in Dynamik and only have it show up when a page has a certain label (sample: Contact sidebar). Code goes to Dynamik Custom - Functions. You will have to create the label first: Go to Dynamik Custom - Labels, name it contact-sidebar, check the checkbox for the conditional and save. Second sample shows a code sample for mul…
// Registering new sidebar
genesis_register_sidebar( array(
'id' => 'contact-sidebar',
'name' => __( 'Contact Page Sidebar'),
'description' => __( 'This is the contact page sidebar section.' ),
) );
// Only add this sidebar when a page has label contact-sidebar
add_action('get_header','siga_custom_contact_sidebar');
<?php
// Retrieves the stored value from the database - put in hook box and choose hook location
$meta_value = get_post_meta( get_the_ID(), '_my_meta_value_key', true );
// Checks and displays the retrieved value
if( !empty( $meta_value ) ) {
echo $meta_value;
}
?>
@SiGaCode
SiGaCode / remove-header-right.php
Created September 5, 2015 11:48
Remove the header-right area entirely.
//* Remove the header right widget area
unregister_sidebar( 'header-right' );
<Files xmlrpc.php>
Order Deny,Allow
Deny from all
Allow from 192.0.64.0/18
Satisfy All
ErrorDocument 403 http://127.0.0.1/
</Files>
@SiGaCode
SiGaCode / show-description.php
Created October 12, 2015 16:40
Show both caption AND description of a picture on pages/posts. http://wordpress.stackexchange.com/questions/48117/how-to-show-description-under-an-inserted-image (Third suggestion from Kovah)
add_shortcode('wp_caption', 'img_caption_add_description');
add_shortcode('caption', 'img_caption_add_description');
function img_caption_add_description($attr, $content = null)
{
$post_id = str_replace('attachment_', '', $attr['id']);
$img = get_post((int)$post_id);
if (is_a($img, 'WP_Post')) {
$attr['caption'] = $img->post_content;
}
/* this doesn't get processed early enough if created in hook boxes, so leave in custom functions */
add_action( 'pre_get_posts' , 'your_modify_search' );
function your_modify_search( $query ) {
if ( ! $query->is_main_query() ) return;
/* else is main query, so process search target */
if ( $query->is_search ) {
$query->set( 'post_type' , 'post' ); /* search posts only, not pages or other */
/* test for search text stored in [s] set to a value, but empty */
if ( isset($_GET['s']) && empty($_GET['s']) ) $query->set( 's' , "[empty search text ]" ); /* sub in whatever empty text you want to use */
}
@SiGaCode
SiGaCode / modified-author-box-50-50.php
Last active November 8, 2015 18:38
Filter the output of the author box to achieve two 50% sections (responsive), right side is one with an image. Credits: Stripped down sample from http://www.billerickson.net/code/customize-author-box/ Using Dynamik classes to preserve the styles set in Dynamik interface.
add_filter( 'genesis_author_box', 'be_author_box', 10, 6 );
/**
* Customize Author Box
* @author Bill Erickson
* @link http://www.billerickson.net/code/customize-author-box
* @param string $output
* @param string $description
*/
function be_author_box( $output, $context, $description ) {