How To Change The CSS In WordPress Gallery
The following snippet will let you change the CSS in WordPress gallery.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
//deactivate WordPress function remove_shortcode('gallery', 'gallery_shortcode'); //activate own function add_shortcode('gallery', 'wpe_gallery_shortcode'); //the own renamed function function wpe_gallery_shortcode($attr) { global $post, $wp_locale; static $instance = 0; $instance++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } else { $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "\n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link($att_id, $size, true) . "\n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instance}"; $gallery_style = $gallery_div = ''; if ( apply_filters( 'use_default_gallery_style', true ) ) $gallery_style = " <style type='text/css'> </style> <!-- see wpe_gallery_shortcode() in wp-includes/media.php -->"; $size_class = sanitize_html_class( $size ); $gallery_div = "<div id='$selector' class='gallery galleryid-{$id} gallery-columns-{$columns} gallery-size-{$size_class}'>"; $output = apply_filters( 'gallery_style', $gallery_style . "\n\t\t" . $gallery_div ); $i = 0; foreach ( $attachments as $id => $attachment ) { $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); $output .= "<{$itemtag} class='gallery-item'>"; $output .= " <{$icontag} class='gallery-icon'> $link </{$icontag}>"; if ( $captiontag && trim($attachment->post_excerpt) ) { $output .= " <{$captiontag} class='wp-caption-text gallery-caption'> " . wptexturize($attachment->post_excerpt) . " </{$captiontag}>"; } $output .= "</{$itemtag}>"; if ( $columns > 0 && ++$i % $columns == 0 ) $output .= ''; } $output .= " </div>\n"; return $output; } |
Snippet Source/Credit: WPEngineer
How To Have Easier Login URL In WordPress
Adding the following snippet below .htaccess, you will be able to have easier login URL in WordPress.
1 |
RewriteRule ^login$ http://yoursite.com/wp-login.php [NC,L] |
Snippet Source/Credit: digwp.com
How To Allow HTML in WordPress User Bio Info
Adding the snippet in theme’s functions.php file and you will be able to have HTML in WordPress user bio info.
1 |
remove_filter('pre_user_description','wp_filter_kses'); |
Snippet Source/Credit: darrenhuskie.com
How To Print Current Template In WordPress
Adding the following snippet to your theme’s functions.php file, you will be able to print current template in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<?php add_action( 'wp_head', 'admin_print_template_used' ); function admin_print_template_used() { global $template, $current_user, $wp_admin_bar; get_currentuserinfo(); if ( !is_user_logged_in() && $current_user->ID != '1' ) return; if ( is_admin_bar_showing() ) $wp_admin_bar->add_menu( array( 'parent' => false, 'id' => 'template', 'title' => $template, 'href' => '#' )); else print_r( $template ); } // START THE SCRIPT TO PUSH ADMIN BAR TO BOTTOM function fb_move_admin_bar() { echo ' <style type="text/css"> body { padding-bottom: 28px; } body.admin-bar #wphead { padding-top: 0; } body.admin-bar #footer { padding-bottom: 28px; } #wpadminbar { top: auto !important; bottom: 0; } #wpadminbar .quicklinks .menupop ul { bottom: 28px; } </style>'; } // on backend area add_action( 'admin_head', 'fb_move_admin_bar' ); // on frontend area add_action( 'wp_head', 'fb_move_admin_bar' ); ?> |
Snippet Source/Credit: Snipplr
How To Manually load Google’s Latest jQuery In WordPress
Using the following snippet below, you will be able to manually load Google’s latest jQuery in WordPress.
1 2 3 |
<?php wp_deregister_script('jquery'); ?> <?php wp_head(); ?> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> |
Snippet Source/Credit: encosia.com
How To Organize WordPress Category Archive Listing By Subcategory
The following snippet below will let you organize WordPress archive listings by subcategory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php $categories = get_categories("child_of=17"); foreach ($categories as $cat) { ?> <div class="genre_subcat"> <?php query_posts("cat=$cat->cat_ID&showposts=-1&order=ASC&orderby=name"); ?> <h2><?php single_cat_title(); ?></h2> <small><?php echo category_description($cat->cat_ID); ?></small> <?php while (have_posts()) : the_post(); ?> <div class="post"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3> <p class="postdate"><?php the_time('F jS, Y') ?></p> <?php the_content(); ?> <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></p> </div> <?php endwhile; ?> </div> <?php }?> |
Snippet Source/Credit: iamnotagoodartist.com