Showing posts with label wp Plugin. Show all posts
Showing posts with label wp Plugin. Show all posts

Saturday, March 23, 2013

How to Make a Featured Post Carousel for WordPress

Conceiving the default likeness
Before we do any thing, proceed to the topics folder of your WordPress installation (wp-content/topics/) and make a backup of the "default" folder. This is the Kubrik theme we will be revising. The backup is in case you desire to revert back to the initial, unmodified topic.

First, we’re going to make a default likeness in the happening no boasted mail image is specified. Let’s hold it sugary and easy for this tutorial. Open up your preferred image editor and conceive a 233x130px rectangle with 10px radius circular corners. I made the backdrop a white to grey radial gradient and put some text on peak. This is what I have:

Add the PHP code
Now for the cipher. Open the “header.php” document interior the “default” folder. At the end of the document, you will glimpse a div impede and an hr tag like this:

<div id="header">
    <div id="headerimg">
        <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
        <div class="description"><?php bloginfo('description'); ?></div>
    </div>
</div>
<hr />

Between the ending div tag and the hr, insert the following code:
<div id="featured">
    <ul id="carousel">
        <?php
        $featured_posts = get_posts('numberposts=3&category=1');
       
        foreach( $featured_posts as $post ) {
            $custom_image = get_post_custom_values('featured_image', $post->ID);
            $image = $custom_image[0] ? $custom_image[0] : get_bloginfo("template_directory")."/images/no-featured-image.jpg";
            printf('<li><a href="%s" title="%s"><img src="%s" alt="%s" /></a></li>', get_permalink($post->ID), $post->post_title, $image, $post->post_title);
        }
        ?>
    </ul>
    <div class="clear"></div>
</div>

Style with CSS
Next we need to add some CSS styles. Open up the “style.css” document and put the following code below at the end of the document. All this does is float the register elements to the left and space them out equally.

/* Featured Post Carousel */

#featured {
    padding: 10px 10px 0 20px;
    }

#carousel {
    list-style: none;
    margin: 0;
    padding: 0;
    }

#carousel li {
    float: left;
    padding: 0;
    margin-right: 10px;



Comprehending the code
Let’s take a look at what the cipher we added does. Inside the canister div (id=”featured”) we have an unordered list and some PHP cipher to develop register elements.

$featured_posts = get_posts('numberposts=3&category=<strong>1</strong>'); 

The first line shown above retrieves the mail data using the get_mails() function and assigns the mail data to the $featured_posts variable. The get_posts() function excepts a single parameter in the form of a query string similar to what you might glimpse at the end of a URL (sans the primary inquiry mark). The first parameter is “numberposts” which we’ve set to 3 for this tutorial. This parameter sets how numerous boasted posts we will be showing. The second parameter is “category” which we’ve set to 1. The worth of the “category” parameter should be the ID of the category you are utilising for your boasted posts. You can find the ID of a class by going to the class administration sheet and hovering your mouse over a class title. The rank bar will display a link. The last number is the class ID. 

The next line is a foreach loop that will loop through the mails we’ve retrieved utilising the get_mails() function. The first line interior the foreach loop retrieves the URL of the image utilising the get_post_custom_values() function and shops the URL in the $custom_image variable. The first parameter identifies the key of the made-to-order value we’re utilising, “featured_image”. The second parameter identifies what post we’re getting the worth from. 
  
$custom_image = get_post_custom_values('featured_image'$post->ID);  


In the next line we do a quick check to see if an image was indeed specified. If no image was specified, we assign the $image variable the URL of the default image. If an image was specified, we use that.

$image = $custom_image[0] ? $custom_image[0] : get_bloginfo("template_directory")."/images/no-featured-image.jpg"; 

In the last line we actually output the list elements. Each element is an image that links to the featured post.
    printf('<li><a href="%s" title="%s"><img src="%s" alt="%s" /></a></li>', get_permalink($post->ID), $post->post_title, $image, $post->post_title); 

Creating Featured Posts
That’s it! Now, whenever you want to feature a post, assign it to the featured category and create a custom value with a key of “featured_image” and a value of the image URL. Images should be 233x130px.
 


   

Monday, March 18, 2013

How to install Simple PayPal Shopping Cart


There are two standard choices for installing a WordPress Plugin. You can either use the seek or Upload functionality.

For this tutorial we will illustrate how to present the setting up by seeking for the yearned plugin.

First log into the manager area of your WordPress installation. Then proceed to Plugins -> Add New.


In the seek field select period from the drop-down list, then enter “Simple Paypal buying Cart” in the text carton and bang the “Search Plugins” button.


The “WordPress Simple Paypal buying Cart” should appear as first result. bang the establish connection for it.


In the new window that will pop-up bang the “Install Now” button.


The plugin will be automatically downloaded and established for your WordPress. Once the setting up is accomplished, click the Activate Plugin link.


The WordPress buying Cart is now installed and you can adjust the settings for it and adapt the choices according to your desires. proceed to backgrounds -> WP Shopping Cart and change the various options.


Bear in brain that it is imperative to go in your Paypal internet message address in alignment to be adept to receive capital for goods you will create on your website.


At the peak of the backgrounds page for the WordPress buying Cart you will glimpse instructions how to create Add to cart buttons on your pages and how to brandish the shopping cart and the goods in it.

In alignment to conceive a new post with a merchandise for your WordPress buying Cart go to mails -> Add New.

Here is an demonstration data you can enter in a new sheet in alignment to conceive a sample merchandise.

go in the desired text and images if you like, and the WordPress buying cart merchandise cipher. Note that you need to change the “Product” and the number in the wp_cart tag to reflect the yearned merchandise name and cost.

For the shopping cart itself we will use the widget for the plugin. proceed to Appearance -> Widgets.

pull and fall the WP Paypal buying Cart widget to the Sidebar.

Friday, March 8, 2013

How to conceive a photo Album in WordPress without a plugin

In the past, we have shown you how to add a gallery in WordPress with a light box effect. That item only wrappings the exterior of the WordPress functionality. Recently, we had a client that liked us to create a photo gallery coordinated by monthly albums. They wanted the user to be adept to bang on the album photo to glimpse all posts recorded in that month’s album. Each photo should have its own individual sheet with data about the person taking photos and their URL. commonly persons would resort to plugins like NextGen Gallery or another to accomplish certain thing like this. We liked to bypass using a third party plugin therefore we determined to use the core-functionality that WordPress boasts to create certain thing that works. In this item, we will show you how to create a monthly photo album gallery in WordPress without a plugin.

What we are trying to make:
Before we start, lets take a gaze at what the final conclusion is suppose to gaze like:
When the client bang on the Albums sheet, they will glimpse an archive in a grid brandish where each album begins out with it’s distinguishing cover and all the photos in it. The concept was to have one album per month. 

If the user bangs on the album’s cover photo, they will be taken to a sheet just for that album where you can give the client some backdrop information as well as records all the photographs in that album.

If the client bangs on the photo, then they will be taken to the single photo sheet where they will see the title of the photograph. Photographer’s title and their site’s URL.

How we are going to make it?
As you can see from the description above, all of the characteristics needed can be finished using the built-in WordPress functionality. We can heal each monthly album as a post, so each album can have its own lone page with some backdrop info etc. Each likeness will be treated as an addition (thus getting its own lone page). We will use the built-in featured thumbnails for album cover photograph. You can use the default posts, if the whole site’s reason is this photo album gallery, but if you have a blog as well, then this desires to be conceived in a custom post kind.

Let’s conceive a Photo Album Gallery

First thing you should do is conceive a site-specific plugin (or even a project-specific plugin).

If you are going to use made-to-order Post kinds for your task, then you should generate the ciphers and paste it in your site-specific plugin. You can furthermore watch our video on how to conceive Custom mail Types.

Next thing you need to do is list added image dimensions in WordPress for the grid display.
Example would be:

1
add_image_size( 'album-grid', 225, 150, true );

After the added likeness dimensions, let’s add some added fields to the newspapers uploader. This will permit you to add Photographer’s title and their URL when you upload each image. This is the cause why we wrote an item about it two days ago.

How to add additional areas to the WordPress newspapers Uploader
one time you have finished this, permits go ahead and add some albums (posts). Upload all images that you desire to attach to that album. Then attach a distinctive cover photo and set it as a boasted image. You can add the backdrop info in the content area of the mail.

Now that you have a couple of albums in the backend, permits put the cipher to brandish it.
Let’s say that your custom mail kind was called albums. So you will conceive a template file called archive-albums.php. Paste the header codes, the footer ciphers, sidebar and other conceive elements that you want. conceive a mail loop. interior that mail loop, we are going to brandish all additions from a mail except the thumbnail which will connection to the single likeness page. We will also add the boasted mail thumbnail (album cover photo) individually and connection that to the single mail page (album page).

We decided to style the grid images using the list element. The code looks like this:

<li class="album-grid"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail('album-grid'); ?></a></li>
 
<?php if ( $post->post_type == 'albums' && $post->post_status == 'publish' ) {
               $attachments = get_posts( array(
                       'post_type' => 'attachment',
                       'posts_per_page' => -1,
                       'post_parent' => $post->ID,
                       'exclude'     => get_post_thumbnail_id()
               ) );
 
               if ( $attachments ) {
                       foreach ( $attachments as $attachment ) {
                               $class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
                               $title = wp_get_attachment_link( $attachment->ID, 'album-grid', true );
                               echo '<li class="' . $class . ' album-grid">' . $title . '</li>';
                       }
                       
               }
        }
?>


The main CSS style that you really have to worry about is the class .album-grid

.album-grid{width: 225px; height: 150px; float: left; list-style: none; list-style-type: none; margin: 0 18px 30px 0px;}

This would permit each likeness to be placed appropriately in the grid, and we will get the method how we desire it.

Next thing you need to do is conceive a single-attachment template. This will be the sheet where the user will be taken to, so they can view each individual likeness. They will glimpse the likeness name, photographer’s title and photographers URL here. You can follow our tutorial on How to Create a Custom Single additions Template in WordPress.

seem free to method the lone template although you like.
Now the only thing left in the register is to conceive an individual albums sheet. afresh presuming that your custom mail kind is called albums, you will need to conceive a single-albums.php file. Copy all the header, footer, sidebar, or any other design components that you want.

In the loop element fundamentally do the same thing that we did with the archive-albums template. Before you add the boasted likeness and the additions grid though, you need to add the album title and description. Which can be finished by easily adding the cipher like this?

<h1><?php the_title(); ?></h1>
<div class="entry-content"><?php the_content(); ?></div>
 
//Insert grid code below this line

Ta ad, we are done. We just created a monthly photo album gallery in WordPress without using any plugin. Let us know if you have any questions.

Create a Multi-Layout Portfolio with WordPress



WordPress, as a content management system, is frequently used for creating portfolio websites. With the progress of consumer interface design and functionalities, a new tendency has emerged: displaying portfolio substance in unrelated layouts. This tutorial particulars the method of creating a committed portfolio section in WordPress’ backend, and using jQuery and CSS3 to display the portfolio in a fashionable approach.

In this tutorial, we are going away to expansively use dominant facial appearance of WordPress, such as custom posts, custom taxonomies, and we’ll also inscribe a function to fetch our personal custom excerpts.

Step 1 - Installing WordPress and Initializing the Theme.

The initial step in building our portfolio website is to install WordPress. This is a easy task, and, even superior, the majority web hosts out there make available one click installers. However, if you are new to this, here is an awesome guide to facilitate you out with the installation.
Once the installation has fulfilled, we should after that create our custom theme which will show our portfolio. There are a variety of methods for creating custom themes. Several like better to create a new blank white template, even as others settle on to create child themes of the new TwentyTen template. For this lesson, we will make use of the Starker's theme, by Elliot Jay Stocks. It's a totally empty theme with no styling; it’s a immense base to create our theme on. Edit the styles.css file, and modify the theme name referenced at the top. To install the theme, merely paste the theme folder in the wp-content > themes folder. Once the theme is installed, you can make active it by obtainable to the themes page.

Step 2 - Planning the Layout

Our portfolio site will not hold much data. A basic portfolio site contains images of the projects, several tags to classify the projects, and a short explanation of each. The multi-layout theme will function in such a manner that the user can select stuck between a grid and list layout. Like numerous multi layout websites accessible, we are not going to fill a unusual page when the user clicks on the list view or the grid view. As an alternative, we’ll use AJAX to asynchronously load in the new observer. This is the essential design of how our portfolio site will emerge in grid mode:

On one occasion the user clicks on the list view manage, the entire layout will smoothly modify to a list view which will include the title of the project, the tags associated with it, and a short explanation.

Step 3 - Setting up the Backend

Intended for our portfolio, we require to register a custom post type, called “project.” We can modify every portion of a WordPress post. For example, we can modify the labels occupied, select various features for the post like to comments, thumbnails, excerpts, etc.
To execute a custom post, edit the functions.php file positioned within the theme folder. It holds a lot of predefined code, as the naked Starkers theme provides some functionalities of the evasion TwentyTen template. Don’t be scared or confused; you can add on the subsequent code either at the bottom or top of the functions.php file.
We fastener our custom function to the initialization (init) action in the subsequent technique:

This project_custom_init method will be used to register the custom post category in the WordPress database.


You can discover in recognize about the method engaged in registering a custom post variety here.
he register_post_type method requires a surname for the custom post, and a set of arguments, which define the individuality of the custom post. Firstly, we need to define the labels for the custom post. These labels will be used for the custom post in the WordPress admin.

On one occasion we’ve distinct the labels, we need to describe the set of influence for the custom post type. The labels array define earlier is going to be an argument as well. Formerly the arguments are defined, we register the custom post nature as “project”.


Create Custom Messages for the 'Project' Post

We can also optionally insert custom post for the custom post type. These post will be showed in the WordPress dashboard while we edit or update the custom post. We can do this by creating a strain for the post simplified messages in the following way:

Registering a Custom Taxonomy

We after that require significant a custom classification for the tags to be used with each of the portfolio items. You can learn more about the register classification manner here.


Go back to your WordPress dashboard, and open the media settings from the settings tag. Here, you comprise to set the evasion bulk for the portfolio image thumbnails. You’ll also observe in the sidebar that the “Project” custom post nature has been effectively registered, along with the custom classification, “tags.” We can inventory the default thumbnail size by means of the set_post_thumbnail method, but I’ll reveal another way to attain this. You can gain knowledge of more about how to place post thumbnail sizes programmatically here.


Create Demo Portfolio Items

Create several demo portfolio items by going away to projects and clicking on add new. We need a title for the project, the content, and a thumbnail. We can observe that a tag segment has also appeared and confirms that our custom classification was effectively registered. Add several tags for the portfolio stuff, as well.

Step 4 Coding and Styling The Template

Coding the static template

To craft the theme, we will first craft a static HTML/CSS3 pattern for the website. This separates the two errands of making the website look unswerving with the design, and enticing the content from the database. Coding the theme openly may be a bit puzzling for beginners occasionally – specially, if a lot of content is exist in the theme. Create three folders, named
“css”, “images” and “js,” respectively. The common formation for the main content locale will be like so:


Style the Template

Styling the template is needy on you. You can research with unlike colors and images to suit your desires. But for this template, we are arrival to create a dark grime theme and use some fun CSS3 to accomplish those slight hover effects and transparency. The slicing up of the design into metaphors is rather. As such, I won’t go over the minutiae here.
The following are the common styles for the project record. We will later do explicit styling for each grid layout manner and a list design mode depending on the current class of the folio list.


Also create note that we are not using the common opacity method of achieving transparency using CSS3. By means of the opacity method also affects the brood of the parent container on which the opacity is useful. As an alternative, we are using the RGBa method of adding up backdrop colors to the container, and using the alpha worth to control the transparency of the container.


You can learn more about the RGBa Property in this remarkable article.


This does not involve the transparency of the children fundamentals. We also need to create IE definite CSS code to sustain the alpha transparency.


In the HTML makeup, you will perceive that there is a class prearranged to the portfolio record.


Essentially, the “grid” class is used to show the list in a grid sight and the “list” class is used to show the list in a list view. In the grid mode, all the extra content is unseen from the user, and in the list manner, all the content is able to be seen to the user. We have two take apart sets of styling for each manner. The styles for the grid manner are as follows:

List manner styles are as follows. At any instant, only one of the grid or list styles is dynamic.


We after that will use jQuery UI to change the class of the folio record with deference to the layout button clicked by the user. We’re detecting the click occasion of the layout manage buttons, enticing the current class and the new class to be activated, and then using the add and remove class methods to modify the classes. We also have a set of parameters which identify the velocity of the events enchanting place.


Step 5 Integration with the WordPress Theme

Now that we have finished the static adaptation of the site, we can amalgamate it with the WordPress theme in a material of minutes. All we require to do is ring through the posts using a wp_query object with a query for the institution post type. Then, we lay the content in the respective position in the template.

Edit header.php

Initially, we need to change the header.php template, and embrace our custom JavaScript files. In this lesson, we’ll embrace jQuery using the Google’s CDN version. We will deregister the jQuery provided by WordPress, and register Google’s CDN version of jQuery. Paste the following snippet in your functions.php file.



Be in motion the css, js and images folders – that you shaped formerly for the motionless template – to the WordPress theme folder. Insert the jQuery UI custom file, and the major script file in the header. Make sure it is inserted below the wp_head technique.


Create the Main Template

At the moment, you can either build a new template in the theme – for example, page-home.php – or you can change the index.php already in attendance in the theme file. If you choose the previous process, then:
  • Build a page
  • Place the page’s template as the template you just fashioned.
  • Go to the interpretation settings in the settings tab.
  • Select the homepage as a motionless one.
  • Choose the page you just fashioned as the homepage.

The template will first contain the header, which you can call using the get_header() method, then the main content, which you will code within the template itself. Lastly, the footer, which you can be included, via the get_footer() method.
The subsequent code demonstrates how you can generate a custom query by means of the wp_query object.

We are using a variable, count to count the figure of items in the catalog. We require this because we will remain only four substance in each line and assign a ‘rightmost‘ class to each fourth list constituent. The ‘rightmost‘ class eliminates any right fringe to the list elements. Alternatively, we could, in our CSS file, use the li:nth-child(4n) selector.

The subsequent code illustrates how we can loop through the posts and insert the content, as required.


Surrounded by the loop, we put in the content in the ordinary WordPress mode, using the $loop wp_query object, of course. The subsequent code displays how we can carry the thumbnail of the project post and interleave it into the template. Make appropriate note of how we use the $count variable to place in the ‘rightmost‘ class on each fourth list ingredient.


Now comes the content part where we require inserting the title, tags, short explanation and fetching the quotation for the post with a custom quotation scheme. Inserting the title is pretty easy, as are the tags. Remember, we formerly created a custom nomenclature by the name of tags.


You will become aware of that we are not by means of the common the_excerpt() process, provided by WordPress. As an alternative, we are essential our own custom technique by adding some filters. The common quotation technique proceeds a better length of quotation than we need. Hence, the custom description. We’re also changing the ‘Continue Reading…’ text added at the end of the default quotation, and replacing it with ‘Read More’. The subsequent snippet serves our purpose. This custom excerpt method comes in handy for profusion of situations.


Step 6 Conclusion

The over technique of creating a multi-layout portfolio is relatively undemanding and uses basic CSS and jQuery tricks to realize the result. Even superior, these techniques can be functional to a variety of projects. Other methods in this lesson, like custom post types, custom taxonomies and adding filters to the passage technique, can be used in various other inventive conducts, as well!

Tab Content Changed using jQuery and WP_Query



Step 1 – New Structural HTML.

We’ll create some extra divs to wrap everything that we’re working with. Place add this following code just above <div id=”wrapper”>: opening tag.
<div id="container">
        <div id="header">
               <h1>MyBlog - WordPress and jQuery together in <em>MyPlugin.</em></h1>
        </div>
               
And we also need to add a final </div> just before the closing </html>

Step 2 – Conditional tags

 Add this code just under our brand new h1 element in index.php.
<?php if(is_home()) {include(TEMPLATEPATH.'/tabbedChangedContent.php'); } ?>
 if(is_home()) is our condition here, so if the page currently being browsed is the home, the include our tabbedChangedContent.php file.

Step 3 – tabbedChangedContent.php (HTML)

Create a new file in our ‘ownTheme’ directory, and name it tabbedChangedContent.php. Type or paste the following into this new file:
<div id="myTabsAndContent">
                       <ul id="myTabsNav">
                               <li><a href="#myRecentArticles">Recent Articles</a></li>
                               <li><a href="#myMonthlyArchives">Monthly Archives</a></li>
                               <li><a href="#mySearchArea">Search</a></li>
                       </ul>
                       <ul id="myTabContent">
                               <li id="myRecentArticles ">
                                      <ul>
                                              <!—RECENT POST GOES HERE -->
                                      </ul>
                               </li>
                               <li id="myMonthlyArchives ">
                                      <ul>
                                              <!-- ARCHIVES PODT GOES HERE -->
                                      </ul>
                               </li>
                               <li id="mySearchArea ">
                                      <!-- SEARCH PAGE GOES HERE -->
                               </li>
                       </ul>
               </div> <!-- div# myTabsAndContent -->
This is just raw HTML without any WordPress or jQuery additions.
#myTabsNav – There are the clickable tabs! We’ve added a href attribute of their corresponding content <li>. Making sure the hrefs match the ID name of their corresponding content list item!
  • #myTabContent – We use a <ul> not unlike WordPress’s sidebars, because it’s easy to style and is essentially a list of content anyway.

Step 4 – myTabbedContent.php (WordPress functions)

So we need to replace the <– –> comments with real content! Now we’ll start with WP_Query(), wp_get_archives(), and a search form.

4.1 – WP_Query()

So cut out the comment tag for our WP_Query, and type the following:
<?php $recentPost = new WP_Query("showposts=5");
        while($recentPost->have_posts()) : $recentPost->the_post();?>
               <li>
                       <a href="<?php the_permalink();?>" title="Link to <?php the_title(); ?>"><?php the_title(); ?></a>
               </li>
<?php endwhile; ?>
Now we’re simply doing, is telling the immanently following loop to show us a list of the 5 latest posts. We can the string within the brackets of WP_Query can be anything… filter by dates, categories, tags, limit, etc.

4.2 – Archives

Now it’s a basic call for a list of monthly archives. And to match the WP_Query section, we only want 5 of them (automatically in descending order). Simply switch the <– WP_ARCHIVES GOES HERE –> in myTabbedContent.php with the following:
               <?php wp_get_archives('type=monthly&limit=5'); ?>

4.3 – Search

We’ll only be using a very simple input and search, using the default search I always use in my own themes. Now we replace the SEARCH PAGE comment with this:
<form method="get" id="mySearchForm" action="<?php bloginfo('home'); ?>">
        <p>
               <input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
               <input type="submit" id="mySearchSubmit" value="Search!" />
        </p>
</form>
Great, so now you should have a new file within the ownTheme directory called myTabbedContent.php, and the conditional tag in index.php.

Step 5 – CSS

At the moment, they are ugly sides. We need to make the page for people without JavaScript enabled first, for graceful degradation. You’ll need some images if you want to make it as pretty just as much as I do. Here is a list of them (right click and save as into the images folder within the ownTheme directory!)
Either type, or paste this massive slab of CSS.
/*------TABS------*/
#container{
        width: 600px;
        margin: 0 auto;
}
h1{
        font-size: 1.3em;
        text-transform: uppercase;
        color: #949494;
        letter-spacing: 1px;
}
#myTabsAndContent ul, #myTabsAndContent li{
        padding: 0
}
ul#myTabsNav{
        float: left;
        width: 200px;
        list-style: none;
}
ul#myTabsNav*:focus {
         outline: none
}
ul#myTabsNav li.active a{
        color: #303030;
}
ul#myTabsNav li a{
        padding: 1em 15px;
        margin: 0 0 1em 0;
        display: block;
        width: 170px;
        text-decoration: none;
        color: #7e7e7e;
        font: 11px/20px Georgia;
        text-transform: uppercase;
}
ul#myTabsNav a:hover{
        color: #0a0a0a
}
ul#myTabsNav {
        margin: 1em 0 0;
        min-height: 180px;
        width: 350px;
        float: left;
        list-style: none;
        padding: 0 25px;
        font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
}
#myTabContent>li{
        width: 350px;
        list-style: none;
        padding: 0 25px 20px 0;
}
#myTabContent li ul li{
        list-style: none;
}
#myTabContent li ul li a{
        display: block;
        border-bottom: 1px solid #e7e7e7;
        padding: 10px 0;
}
form{
        padding: 30px;
}
form input{
        border: 2px solid #cbc6c9;
        border-right: 0;
        padding: 5px;
        margin-right: 0;
        color: #fff;
        font: 16px Georgia, "Times New Roman", Times, serif;
}
#mySearchSubmit{
        border-left: 0;
        border-right: 2px solid #cbc6c9;
        margin-left: 0;
        position: relative;
        left: -3px;
        color: #00416c;
}
#mySearchSubmit:hover{
        background: url(images/tabContentHover.png) no-repeat center;
        color: #003459;
        cursor: pointer;
}

Step 5 – jQuery

Let’s put into words what we need to happen:
  1. Hide all list items we don’t want to see initially, showing only our first content section, the WP_Query section.
  2. Add the class ‘active’ to the first tab, because it’s corresponding section is open.
  3. When a tab is clicked, do the following in order:
    • Eliminate the active class from the currently active tab
    • Include the class active to the tab that has just been clicked
    • Get the href attribute of the a within the clicked tab, and make it our new variable ‘target’
    • Then have the target reveal itself, and the previous showing area hide itself with some simulation
This goes within the jQuery(document).ready(function(){ });, underneath th hero and villain script.
//And our little animated sliding area uptop of the design.
        jQuery('#tabContent>li:gt(0)').hide();
        jQuery('#tabsNav li:first').addClass('active');
        jQuery('#tabsAndContent #tabsNav li').bind('click', function() {
               jQuery('li.active').removeClass('active');
               jQuery(this).addClass('active');
               var target = $('a', this).attr('href');
               jQuery(target).slideDown(400).siblings().slideUp(300);
               return false;
        });

To finish up.

We’ve gone through a lot in this tutorial.
  • WP_Query(); – A great tool for getting content outside the main loop.
  • WordPress conditional tags – unbelievable for further customizing your theme.
  • .bind function – to easily link a function to a specific element with an event.
  • jQuery animation – amazingly easy to implement, and as pretty as a garden of roses.