Skip to content

Instantly share code, notes, and snippets.

View jayseventwo's full-sized avatar

jayseventwo jayseventwo

View GitHub Profile
/*
Make the Facebook Like box responsive (fluid width)
https://developers.facebook.com/docs/reference/plugins/like-box/
*/
/* This element holds injected scripts inside iframes that in some cases may stretch layouts. So, we're just hiding it. */
#fb-root {
display: none;
}
@jayseventwo
jayseventwo / Display date of all posts
Created July 23, 2013 05:12
In wordPress, when more than 1 post is added per day, the date only shows for the first post. This fixes that issue. Add to content.php
/* --- replace this --*/
<time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_date(); ?></time>
/* -- with this */
<time datetime="<?php echo the_time('Y-m-j'); ?>" pubdate><?php the_time(get_option('date_format')); ?></time>
@jayseventwo
jayseventwo / Add pagination to WordPress
Created June 25, 2013 03:01
Add pagination to WordPress posts/pages - this example us using the Roots theme.
/*--- add to functions/custom.php */
/* ---------------------------------- custom pagination for posts -----*/
function j72_pagination($pages = '', $range = 2)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
@jayseventwo
jayseventwo / sticky nav menu - twitter bootstrap
Created June 17, 2013 05:46
Create a sticky top nav menu using Twitter bootstrap - also works in WordPress themes based on Twitter Bootstrap
<!-- for fixed menu - surround nav menu -->
<div data-spy="affix" data-offset-top="200">
... header and nav menu ...
</div>
<!-- add to css -->
.affix {
top: 20px !important;
@jayseventwo
jayseventwo / add custom menu to page using shortcode
Created May 29, 2013 07:07
Add a WordPress custom menu to a page/post using a shortcode - add to functions.php
/* --------------------------------------------------add custom menu to page using shortcode
add [custommenu menu=Menu-name-here] to page*/
function custom_menu_shortcode( $atts, $content = null ) {
extract( shortcode_atts(
array(
'menu' => '',
'container' => 'div',
'container_class' => '',
'container_id' => '',
@jayseventwo
jayseventwo / Custom widget area
Created May 23, 2013 04:58
Create a custom widget area.
// add to functions.php
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Right header',
'id' => 'custom-widget-01',
'description' => 'Widget Area',
'before_widget' => '<div id="one" class="two">',
'after_widget' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>'
@jayseventwo
jayseventwo / Create custom taxonomy
Created May 15, 2013 03:22
Create custom taxonomy - add to functions.php
/*-------------------------------------------------------------------------skills for portfolio custom post type -*/
register_taxonomy("Skills", array("portfolio"), array("hierarchical" => true, "label" => "Skills", "singular_label" => "Skill", "rewrite" => true));
@jayseventwo
jayseventwo / Display WordPress categories
Last active December 17, 2015 06:39
Display WordPress categories - add to functions.php
class DisplayCategoriesWidget extends WP_Widget
{
function DisplayCategoriesWidget()
{
$widget_ops = array('classname' => 'DisplayCategoriesWidget', 'description' => 'Displays categories' );
$this->WP_Widget('DisplayCategoriesWidget', 'Display Categories Widget', $widget_ops);
}
function form($instance)
{
@jayseventwo
jayseventwo / Shortcodes in sidebar (text) widgets
Created May 11, 2013 04:42
Shortcodes in sidebar (text) widgets
// Shortcodes in sidebar (text) widgets
//
add_filter('widget_text', 'do_shortcode', 11);
@jayseventwo
jayseventwo / Remove autop from WordPress pages
Created May 5, 2013 07:32
Remove autop from WordPress pages. Make sure you have “custom fields displaying from screen menu at top of page. Add to functions.php
function disable_autop() {
global $post;
$disable_autop_var = get_post_meta($post->ID, 'disable_autop', TRUE);
if ( !empty( $disable_autop_var ) ) {
remove_filter('the_content', 'wpautop');
}
}
add_action ('loop_start', 'disable_autop');