Skip to content

Instantly share code, notes, and snippets.

View rickrduncan's full-sized avatar

Rick R. Duncan rickrduncan

View GitHub Profile
/* Use CSS to customize WordPress widget titles */
.widget-area .widget_recent_entries h4 {
background: url("images/image-name.png") no-repeat scroll left 6px transparent;
padding-left: 40px;
}
.widget-area h4 {
border-bottom: 4px double #ccc;
border-top: 4px double #ccc;
font-size: 24px;
@rickrduncan
rickrduncan / widget-title-2.php
Last active January 11, 2016 11:19
Method 2: Customize WordPress widget title.Full tutorial: http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
<?php
//* Do NOT include this comment or the opening php tag above
//* Insert SPAN tag into widgettitle
add_filter( 'dynamic_sidebar_params', 'b3m_wrap_widget_titles', 20 );
function b3m_wrap_widget_titles( array $params ) {
// $params will ordinarily be an array of 2 elements, we're only interested in the first element
$widget =& $params[0];
$widget['before_title'] = '<h4 class="widgettitle"><span class="sidebar-title">';
$widget['after_title'] = '</span></h4>';
<?php
//* Do NOT include this comment or the opening php tag above
//* Wrap first word of widget title into a span tag
add_filter ( 'widget_title', 'b3m_add_span_widgets' );
function b3m_add_span_widgets( $old_title ) {
$title = explode( " ", $old_title, 2 );
if ( isset( $title[0] ) && isset( $title[1] ) ) {
@rickrduncan
rickrduncan / widget-title-4.php
Last active December 20, 2015 06:48
Method 4: Customize WordPress widget title. Full tutorial: http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
<?php
//-> Do NOT include the opening php tag
// Step 2: Place code below into your theme's functions.php file
if ( include( 'custom_widgets.php' ) ){
add_action( "widgets_init", "load_custom_widgets" );
}
function load_custom_widgets() {
unregister_widget( "WP_Widget_Text" );
register_widget( "WP_Widget_Text_Custom" );
@rickrduncan
rickrduncan / custom_widgets.php
Created July 26, 2013 11:13
Method 4: Customized Recent_Posts widget class Full tutorial: http://www.rvamedia.com/wordpress/customize-wordpress-widget-title
<?php
/**
* Recent_Posts widget class
*
* @since 2.8.0
*/
class WP_Widget_Recent_Posts_Custom extends WP_Widget_Recent_Posts {
function __construct() {
<script type="text/javascript">// <![CDATA[
jQuery(document).ready(function($){
/* prepend menu icon */
$('#title-area').append('<div id="mobile-menu"></div>');
/* toggle nav */
$("#mobile-menu").on("click", function(){
$("#nav_menu-2").slideToggle();
$(this).toggleClass("active");
});
@rickrduncan
rickrduncan / google-adsense-archive-2.php
Last active September 19, 2020 16:01
Add Google AdSense into WordPress category pages.
<!-- STEP 2 -->
<!-- The code below is placed into a file named adsense-archive.php as noted in the Gist above. -->
<div id="archive-adsense-wrapper">
<div class="ad-left">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxxx";
google_ad_slot = "xxxxxxxxx";
google_ad_width = 250;
google_ad_height = 250;
@rickrduncan
rickrduncan / schema-logo.php
Last active May 15, 2017 08:05
Filter the Genesis 2.0 SEO title to remove the H1 tag and implement the Organization/Logo schema.
<?php
//* Do NOT include the opening php tag
//* Add Organization schema to our logo
//* Note that logo location is not inside WordPress. It's in a folder named 'img' off of the root of website.
add_filter( 'genesis_seo_title', 'b3m_header_title', 10, 3 );
function b3m_header_title( $title, $inside, $wrap ) {
$inside = sprintf( '<div itemscope="itemscope" itemtype="http://schema.org/Organization"><a itemprop="url" href="%s" title="%s"><img class="logo" itemprop="logo" src="http://www.YOUR-DOMAIN.com/img/YOUR-LOGO.png" alt="%s" /></a></div>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
return sprintf( '<%1$s id="title">%2$s</%1$s>', 'span', $inside );
}
<?php
//* Do NOT include the opening php tag
/**
* Custom Post-Info with Google Rich Snippet support
* @link: https://gist.github.com/rickrduncan/6494748
* @author: Rick R. Duncan - www.rvamedia.com
* @credits: Greg Rickaby & Brad Dalton
*/
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );