Disabling Plugin Stylesheet

You must have seen that WordPress plugins can slow your site down with additional HTTP Requests such as adding their own stylesheet. For advanced users, who are adding custom styles for the announcement, you do not need to have an additional HTTP request for a useless stylesheet. Then add the following function in your theme’s functions.php file:

<?php
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
    function my_deregister_styles() {
    wp_deregister_style( 'ninja-annc-css' );
}
?>
Advertisements

WordPress: Disabling Plugin Stylesheet

You must have seen that WordPress plugins can slow your site down with additional HTTP Requests such as adding their own stylesheet. For advanced users, who are adding custom styles for the announcement, you do not need to have an additional HTTP request for a useless stylesheet. Then add the following function in your theme’s functions.php file:

<?php
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );
    function my_deregister_styles() {
    wp_deregister_style( 'ninja-annc-css' );
}
?>

WordPress 2.9 Post Thumbnail Function

post_thumbnailWordPress 2.9 brings a new function for users of gallery’s the add_theme_support(‘post-thumbnails’) function. with this you will get a new item on your new post window named Post Thumbnail (see right).  After you have added a post Thumbnail to a post, you need to display it.  By using a “gallery” category, creating the below two files (or adding the code to files) and editing your category.php file, you may display a custom gallery page.

To start, create a new file named gallery-function.php and add the following code to it, this file should live in the root of your current theme’s directory.

gallery-function.php

<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>gallery-function.css" type="text/css" media="screen" />
<div id="gallerypost-<?php the_ID(); ?>">
    <div id="gallerypost_main-<?php the_ID(); ?>">
	<div id="gallerypost_thumbnail-<?php the_ID(); ?>">
		<?php post_thumbnail(); ?>
	</div>
	<div id="gallerypost_body-<?php the_ID(); ?>">
		<?php $images =& get_children( 'post_type=attachment&post_mime_type=image' ); ?>
		<h2><a rel="bookmark" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
		<div><small>Posted by <?php the_author_posts_link(); ?> on <?php the_time('F jS, Y') ?></small></div>
		<div>
			<?php the_excerpt(); ?>
		</div>
	</div>
    </div>
    <div id="gallerypost_sub-<?php the_ID(); ?>">
	<div id="gallerypost_sub_left-<?php the_ID(); ?>">
		<p><?php echo get_the_term_list( $post->ID, 'people', 'Who: ', ', ', '<br />' ); ?></p>
		<p><?php echo get_the_term_list( $post->ID, 'events', 'What: ', ', ', '<br />' ); ?></p>
             	<p><?php echo get_the_term_list( $post->ID, 'places', 'Where: ', ', ', '' ); ?></p>
	</div>
	<div id"gallerypost_sub_right-<?php the_ID(); ?>">
		This Album contains <?php echo $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_parent = '$post->ID' AND post_type = 'attachment'" ); ?> items.
	</div>
    </div>
</div>

Next create a file named gallery-function.css and also add it to our current theme’s root directory.
gallery-function.css

.gallerypost {
        background-color:#fff;
        display: block;
        hNeight: 300px;
        margin: 0px 0px 10px 0px;
        padding: 20px 10px 10px 10px;
        overflow: hidden;
        border-bottom: 1px solid #D2C4A2;
        }
.gallerypost_body {
        float: right;
        width: 430px;
        margin: 0 20px 0 0;
        }
.gallerypost_body p {
        margin: 50px 0px 0px 0px;
        }
.gallerypost_body .entry p {
        margin: 0px 0px 0px 0px;
        }
.gallerypost_body .entry {
        margin: 0px 0px 0px 0px;
        }
.gallerypost_main {
        width: 690px;
        }
.gallerypost_sub {
        display: block;
        padding: 210px 0px 0px 10px;
        }
.gallerypost_sub {
        display: block;
        padding: 210px 0px 0px 10px;
        }
.gallerypost_sub p {
        vertical-align: bottom;
        margin: 0;
        }
.gallerypost_sub_left {
        width: 220px;
        display: block;
        float: left;
        }
.gallerypost_sub_right {
        width: 220px;
        display: block;
        float: right;
        }
.gallerypost_thumbnail {
        float: left;
        }
.gallerypost_thumbnail img {
        margin: 0 0 0 10px;
        color: #000;
        }

And lastly you will need to add the following to your functions.php file in your current theme’s root directory (you may add it anywhere in functions.php).

add_theme_support('post-thumbnails');
set_post_thumbnail_size(200, 200);

Now that we have our functions built, we need to add some code to your category.php file.

Right after:

<?php while (have_posts()) : the_post(); ?>

Add the following code.  This will display the gallery-function.php code when a post is in the “gallery” category.

<? if ( is_category( 'gallery' )) {
                    include('gallery-index.php');
               } else { ?>

Next Before:

<?php endwhile; ?>

Add the following to close the if statement.

<?php } ?>

And that should do it, you should now see the post image on the gallery category page similar to below.

Gallery-screenshot

Adding a native WordPress gallery

I have heard a lot of talk lately of people complaining that they are unable to have image gallery’s in WordPress 2.8= without adding a plugin.  I assume this assumption comes from how hard it is to see what you can do when it comes to the gallery functions built into WordPress.   If you look at my gallery page, you will see a simple native WordPress gallery.  This gallery was built threw the theme but uses WordPress as it’s backend.

So How do I build a native WordPress gallery?

Well there’s two parts to accomplishing this successfully, but I’m only going to show you the first part in this post.  First you need to create a Category for all your gallery posts to be filed under. This Category may be named anything you would like it to be named.  I’m going to stick with the simple name of ‘Gallery’.  You will need some posts to be filed under it.  Create a new post as you normally would.  It is best to put some text to tell you readers what this gallery is all about, but that’s not needed.

Once you are ready to create your gallery, switch the editer from ‘Visual’ mode to ‘HTML’ mode (on the top right).  Once in ‘HTML’ mode, enter:

[ gallery ]

note: there should be no space between the brackets and the word ‘gallery’ (if I were to enter this line on my page, without the spaces, I would create a gallery).

Now switch back to the ‘Visual’ mode and you should see a new yellow box in your post box with an image of a camera with a photograph behind it.  If you move your mouse over this new yellow box, two new icons will appear.  From this point, just upload photos to your site and save it.

After you have uploaded your images, save the post and check it out on your website.  Depending on your theme, you should see a nice full gallery on your page, or as I have, just a single thumbnail on your index page, but the full gallery on the posts page.