Skip to content

Instantly share code, notes, and snippets.

Bruce Munson WebEndevSnippets

Block or report user

Report or block WebEndevSnippets

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@WebEndevSnippets
WebEndevSnippets / functions.php
Created Oct 20, 2012 — forked from billerickson/functions.php
WordPress: Limit Homepage to One Category
View functions.php
/**
* 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 Oct 20, 2012
Genesis: Customize 'Return to Top'
View functions.php
/** 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 Oct 20, 2012
Genesis: Reposition Footer Outside Main Wrap
View functions.php
/** 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 Oct 20, 2012
WordPress: Add Login In Navigation (w Profile)
View functions.php
// 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 Oct 20, 2012
JavaScript: jQuery Toggle
View core.js
/**** 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 Oct 20, 2012 — forked from wpsmith/genesis_site_layout.php
Genesis: Force Specific Layout on a page
View genesis_site_layout.php
/**** 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 Oct 23, 2012
WordPress: Add Post ID to Admin Posts/Pages
View functions.php
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 Oct 23, 2012
WordPress: Add Category ID in Admin
View functions.php
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 Oct 27, 2012
WordPress: Add Manual Excerpt Word Counter
View functions.php
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 Oct 28, 2012
WordPress: Customize 'Read More' on Excerpts
View functions.php
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>';
}
You can’t perform that action at this time.