Skip to content

Instantly share code, notes, and snippets.

View jayseventwo's full-sized avatar

jayseventwo jayseventwo

View GitHub Profile
@jayseventwo
jayseventwo / shortcodes.php
Last active December 15, 2015 05:29
Add Bootstrap Twitter shortcodes dropdown to your page/post editor when using Roots Theme. Also adds shortcode ability to widgets. Add this custom.php.
/**
* --------------------------------------------------------------------------------------------------------------------------- Add shortcodes */
add_shortcode('row', 'j72_row' );
add_shortcode('span', 'j72_span' );
add_shortcode('span4', 'j72_span4' );
add_shortcode('span5', 'j72_span5' );
add_shortcode('span6', 'j72_span6' );
add_shortcode('well', 'j72_well' );
add_shortcode('button', 'j72_button');
@jayseventwo
jayseventwo / show-if-certain-category
Created April 24, 2013 03:49
Show/hide certain page elements depending on category (useful for custom post types).
<?php if ( 'portfolio' == get_post_type() ) { ?>
portfolio
<?php } else { ?>
blog
<?php } ?>
@jayseventwo
jayseventwo / Roots theme - hide page header on home page
Created April 24, 2013 03:50
open templates/page-header.php and replace with:
<?php if( !is_front_page() ):?>
<div class="page-header">
<h1><?php echo roots_title(); ?></h1>
</div>
<?php endif;?>
@jayseventwo
jayseventwo / Add custom menus to WordPress
Created April 24, 2013 03:52
Example code shown in lib/init.php for Roots theme or you can add to custom/functions.php
register_nav_menus(array(
'primary_navigation' => __('Primary Navigation', 'roots'),
'header-menu' => __( 'Header Menu' ) ,
'footer-menu' => __( 'Footer Menu' )
));
@jayseventwo
jayseventwo / Add featured image to blog archives page
Created April 24, 2013 03:55
Add featured image to the search/blog archive results. Add to templates/content.php in Roots theme
@jayseventwo
jayseventwo / WordPress - Hide plugins from admin area
Last active December 16, 2015 14:29
Hide certain plugins from the plugins page in WordPress
function hideplugins() {
global $wp_list_table;
$hidearr = array('plugin-folder/plugin.php');
$myplugins = $wp_list_table->items;
foreach ($myplugins as $key => $val) {
if (in_array($key,$hidearr)) {
unset($wp_list_table->items[$key]);
}
}
}
@jayseventwo
jayseventwo / WordPress - style login page
Created April 24, 2013 03:57
Enable styling of the WordPres login page. Add to custom.php in Roots theme.
function custom_login_css() {
echo '<link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().'/assets/css/app.css" />';
}
add_action('login_head', 'custom_login_css');
@jayseventwo
jayseventwo / WordPress - fix nav menu highlighting issue when using custom post type
Created April 24, 2013 04:00
Fix nav menu issues with custom post types. If, when you link to a custom post type in your nav menu, the blog page also highlights the nadd the following to your functions.php, where "menu-portfolio" is the name of the nav menu item you need to fix.
function fix_portfolio_parent($menu){
global $post;
if ( 'portfolio' == get_post_type() )
{
$menu = str_replace( 'current_page_parent', '', $menu ); // remove all current_page_parent classes
$menu = str_replace( 'menu-portfolio', 'current_page_parent menu-portfolio', $menu ); // add the current_page_parent class to the page you want
}
return $menu;
}
add_filter( 'nav_menu_css_class', 'fix_portfolio_parent', 0 );
@jayseventwo
jayseventwo / Custom size images in WordPress
Created April 24, 2013 04:01
Create a custom size for your new image uploads. Add to functions.php
// custom image size for slider
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'new-size', 900, 400, true ); //(add new size here)
}
add_filter('image_size_names_choose', 'my_image_sizes');
function my_image_sizes($sizes) {
$addsizes = array(
"new-size" => __( "New Size")
@jayseventwo
jayseventwo / WordPress - Link featured image to larger version
Created April 24, 2013 04:02
Link post thumbnail (such as featured image) to larger version.