Skip to content

Instantly share code, notes, and snippets.

View WebEndevSnippets's full-sized avatar

Bruce Munson WebEndevSnippets

View GitHub Profile
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 20, 2012 13:04 — forked from billerickson/functions.php
WordPress: Limit Homepage to One Category
/**
* Limit homepage to one category
*
*/
function we_home_query( $query ) {
if( $query->is_main_query() && $query->is_home() && !is_admin() )
$query->set( 'category_name', 'sample-category' );
}
add_action( 'pre_get_posts', 'we_home_query' );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 20, 2012 15:10
Genesis: Customize 'Return to Top'
/** Customize the 'Return to Top of Page' */
add_filter( 'genesis_footer_backtotop_text', 'photos4life_footer_backtotop_text' );
function photos4life_footer_backtotop_text($backtotop) {
$backtotop = '[footer_backtotop text="Back To Top"]';
return $backtotop;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 20, 2012 15:11
Genesis: Reposition Footer Outside Main Wrap
/** Reposition footer outside main wrap */
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
add_action( 'genesis_after', 'genesis_footer_markup_open', 5 );
add_action( 'genesis_after', 'genesis_do_footer' );
add_action( 'genesis_after', 'genesis_footer_markup_close', 15 );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 20, 2012 15:30
WordPress: Add Login In Navigation (w Profile)
// Add Login Link in Navigation
add_filter( 'wp_nav_menu_items', 'we_nav_login_right', 10, 2 );
function we_nav_login_right($menu, $args) {
$args = (array)$args;
$login = wp_loginout( $_SERVER['REQUEST_URI'], false );
$profile = '<a class="profile" href=' . get_edit_profile_url($userid) . '>Profile</a>';
//if not primary, return
//change primary to secondary for secondary menu (though will need some CSS done)
if ( $args['theme_location'] != 'primary' )
@WebEndevSnippets
WebEndevSnippets / core.js
Created October 20, 2012 18:25
JavaScript: jQuery Toggle
/**** Toggle ****/
$('.toggle').next('.toggle-content').hide();
$('.toggle').click(function() {
$('.active').not(this).toggleClass('active').next('.toggle-content').slideToggle('slow');
$(this).toggleClass('active').next().slideToggle('slow');
});
@WebEndevSnippets
WebEndevSnippets / genesis_site_layout.php
Created October 20, 2012 23:11 — forked from wpsmith/genesis_site_layout.php
Genesis: Force Specific Layout on a page
/**** Truly Force Layout without allowing the User to Override the preferred/recommended layout ****/
// Force Full Width Layout
add_filter( 'genesis_site_layout', '__genesis_return_full_width_content' );
// Force Content-Sidebar Layout
add_filter( 'genesis_site_layout', '__genesis_return_content_sidebar' );
// Force Sidebar-Content Layout
add_filter( 'genesis_site_layout', '__genesis_return_sidebar_content' );
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 23, 2012 16:42
WordPress: Add Post ID to Admin Posts/Pages
add_filter('manage_posts_columns', 'we_posts_columns_id', 5);
add_action('manage_posts_custom_column', 'we_posts_custom_id_columns', 5, 2);
add_filter('manage_pages_columns', 'we_posts_columns_id', 5);
add_action('manage_pages_custom_column', 'we_posts_custom_id_columns', 5, 2);
/**
* Add Post ID to posts, pages admin columns
*
*/
function we_posts_columns_id($defaults){
$defaults['we_post_id'] = __('ID');
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 23, 2012 16:43
WordPress: Add Category ID in Admin
add_filter( 'manage_edit-category_columns', 'we_categoriesColumnsHeader' );
add_filter( 'manage_category_custom_column', 'we_categoriesColumnsRow', 10, 3 );
/**
* Add Category ID column in admin
*
*/
function we_categoriesColumnsHeader($columns) {
$columns['catID'] = __('ID');
return $columns;
}
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 27, 2012 14:59
WordPress: Add Manual Excerpt Word Counter
add_action( 'admin_head-post.php', 'we_excerpt_count_js' );
add_action( 'admin_head-post-new.php', 'we_excerpt_count_js' );
/**
* Add Manual Excerpt Word Counter in Posts
*
*/
function we_excerpt_count_js() {
echo '<script>jQuery(document).ready(function(){
jQuery("#postexcerpt .handlediv").after("<div style=\"position:absolute;top:0px;right:5px;color:#666;\"><small>Excerpt length: </small><input type=\"text\" value=\"0\" maxlength=\"3\" size=\"3\" id=\"excerpt_counter\" readonly=\"\" style=\"background:#fff;\"> <small>word(s).</small></div>");
jQuery("#excerpt_counter").val(jQuery("#excerpt").val().split(/\S+\b[\s,\.\'-:;]*/).length - 1);
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 28, 2012 15:20
WordPress: Customize 'Read More' on Excerpts
add_filter( 'excerpt_more', 'we_read_more_link' );
add_filter( 'get_the_content_more_link', 'we_read_more_link' );
add_filter( 'the_content_more_link', 'we_read_more_link' );
/**
* Customize Read More on Excerpts
*
*/
function we_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '"> [More &#x2026;]</a>';
}