Skip to content

Instantly share code, notes, and snippets.

@kraftbj
kraftbj / functions.php
Last active December 14, 2015 07:58
Change Speak Your Mind based on post type. Code should be added to functions.php
/** Modify the speak your mind text based on post type*/
add_filter( 'genesis_comment_form_args', 'custom_comment_form_args' );
function custom_comment_form_args($args) {
if ( 'recipe' == get_post_type() ) {
$args['title_reply'] = 'Tell Us About The Meal!';
return $args;
}
else {
$args['title_reply'] = 'Leave a comment';
return $args;
@kraftbj
kraftbj / single-recipe.php
Last active December 14, 2015 07:59
Changing many elements in Genesis specific to a CPT
<?php
// all of the various add/remove functions
add_filter( 'genesis_comment_form_args', 'custom_cpt_comment_form_args' );
remove_action('genesis_post_title', 'genesis_do_post_title');
// custom functions start here
function custom_cpt_comment_form_args($args) {
$args['title_reply'] = 'Blog Me!';
return $args;
}
@kraftbj
kraftbj / functions.php
Last active December 14, 2015 12:09
Change number of items returned on home page only (Genesis)
add_action( 'pre_get_posts', 'change_number_of_posts_home' );
function change_number_of_posts_home( $query ) {
global $wp_the_query;
if( $query->is_main_query() && is_home() ) {
$query->set( 'posts_per_page', '15' );
}
}
@kraftbj
kraftbj / gist:5084917
Last active December 14, 2015 12:18
Force full width in Genesis
/** Force full width layout */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
$opt = 'full-width-content'; // You can change this to any Genesis layout
return $opt;
}
/** Other options include:
* content-sidebar
* sidebar-content
<?php
// Register newsletter widget area
genesis_register_sidebar( array(
'id' => 'newsletter',
'name' => __( 'Newsletter', 'custom-theme' ),
'description' => __( 'This is the newsletter section.', 'custom-theme' ),
) );
// Add the newsletter widget after the post content
@kraftbj
kraftbj / gist:5221737
Created March 22, 2013 14:37
Remove primary sidebar from genesis
//the below is correct
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
// below is not correct
remove_action( ‘genesis_sidebar’, ‘genesis_do_sidebar’ );
// the difference is the "fancy quotes", they aren't true single-quotes so PHP will ignore them.
@kraftbj
kraftbj / gist:6919947
Created October 10, 2013 15:06
Remove layout options in Genesis
/** Unregister site layouts */
genesis_unregister_layout( 'sidebar-content' );
genesis_unregister_layout( 'full-width' );
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
@kraftbj
kraftbj / functions.php
Created January 31, 2014 18:49
Use image from the latest post for the og:image tag on the home page
<?php
function fb_home_image( $tags ) {
if ( is_home() ) {
$latest_post = get_posts("post_type=post&numberposts=1");
$latest_post = $latest_cpt[0]->ID;
if ( class_exists( 'Jetpack_PostImages' ) ) {
$post_images = Jetpack_PostImages::get_images( $latest_post, array( 'width' => 200, 'height' => 200 ) );
if ( $post_images && !is_wp_error( $post_images ) ) {
$image = array();
@kraftbj
kraftbj / functions.php
Last active September 5, 2024 01:46
Add publicize support to the WooCommerce Product CPT
<?php
add_action('init', 'kraft_woo_publicize');
function kraft_woo_publicize() {
add_post_type_support( 'product', 'publicize' );
}
@kraftbj
kraftbj / custom-facebook-admin-tag.php
Last active April 1, 2021 18:42
Add FB Admins meta tag
<?php
/*
* Plugin Name: Custom Facebook Admin Meta Tag
*/
function custom_facebook_admin_meta_tag() {
$userid = "123456";
$meta = '<meta property="fb:admins" content="' . esc_attr($userid) .'">';
echo $meta;