Skip to content

Instantly share code, notes, and snippets.

@topleague
topleague / twitter-card-genesis.php
Created September 2, 2017 18:55
Code for Adding Twitter Cards
//Code for Adding Twitter Cards
add_action('wp_head', 'add_twitter_cards');
function add_twitter_cards() {
if(is_single()) {
$tc_url = get_permalink();
$tc_title = get_the_title();
$tc_description = get_the_excerpt();
$tc_image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), full );
$tc_image_thumb = $tc_image[0];
$tc_author = str_replace('@', '', get_the_author_meta('twitter'));
@topleague
topleague / list-recent-post-widget-genesis.php
Created September 2, 2017 19:05
Customize Lists in Recent Posts Widget
// Customize Lists in Recent Posts Widget
class Genesis_Widget_Recent_Posts extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_recent_entries', 'description' => __( "The most recent posts on your site") );
parent::__construct('recent-posts', __('Recent Posts'), $widget_ops);
$this->alt_option_name = 'widget_recent_entries';
add_action( 'save_post', array($this, 'flush_widget_cache') );
add_action( 'deleted_post', array($this, 'flush_widget_cache') );
@topleague
topleague / similar-post-genesis.php
Created September 2, 2017 19:12
Populate Similar Posts in Genesis
//* Populate Similar Posts
function related_posts_categories() {
if ( is_single ( ) ) {
global $post; $count = 0; $postIDs = array( $post->ID ); $related = ''; $cats = wp_get_post_categories( $post->ID );
$catIDs = array( );{
foreach ( $cats as $cat ) {
$catIDs[] = $cat;
}
@topleague
topleague / display-similar-post-genesis.php
Created September 2, 2017 19:14
Display Similar Posts in Genesis
//* Display Related Post After Entry Content (blog post)
add_action( 'genesis_after_entry_content', 'related_posts_categories' );
@topleague
topleague / html-tag-excerpts-genesis.php
Created September 3, 2017 05:29
Use HTML Tags in Genesis Excerpts
add_filter('get_the_content_limit_allowedtags', 'genesiswp_custom_allowedtags');
function genesiswp_custom_allowedtags() {
return '<script>,<style>,<b>,<br>,<em>'; //add whatever tags you want to this string
}
@topleague
topleague / html-tag-excerpts-wordpress.php
Created September 3, 2017 05:31
Use HTML Tags in WordPress Excerpts
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
// remove shortcode
$content = preg_replace("/\/", '', $content);
// short codes are applied
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content,'
,<b>,<strong>,<a>,<i>,
@topleague
topleague / remove-layout-genesis.php
Created September 3, 2017 06:44
Remove Unwanted Layout in Genesis
//* Remove content/sidebar layout
genesis_unregister_layout( 'content-sidebar' );
//* Remove sidebar/content layout
genesis_unregister_layout( 'sidebar-content' );
//* Remove content/sidebar/sidebar layout
genesis_unregister_layout( 'content-sidebar-sidebar' );
//* Remove sidebar/sidebar/content layout
@topleague
topleague / display-genesis-blog-grid-layout.php
Last active December 3, 2019 07:11
Display Genesis Blog in Grid Layout
//* Grid Style Content Archive
function be_archive_post_class( $classes ) {
// Don't run on single posts or pages
if( !is_home() )
return $classes;
$classes[] = 'one-half';
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 2 )
$classes[] = 'first';
return $classes;
@topleague
topleague / Markup-Responsive-Menu-Settings.php
Last active September 4, 2017 11:45
Updating Markup in Responsive Menu Settings in Genesis Sample Theme
//* Set the Markup in Responsive Menu Settings Sections of Functions.php
// Credit: Sridhar Katakam
// Step #1 : Locate the following code in functions.php
// Define our responsive menu settings.
function genesis_sample_responsive_menu_settings() {
$settings = array(
'mainMenu' => __( 'Menu', 'genesis-sample' ),
@topleague
topleague / animated-hamburger-menu-genesis.css
Last active December 3, 2019 07:11
CSS for Animated Hamburger Menu Icon in Genesis
/* CSS for Animated Hamburger Menu Icon */
@media only screen and (max-width: 1023px) {
// Hamburgers
.hamburger {
padding: 15px 15px;
display: inline-block;
cursor: pointer;