Wordpress and Webdesign Forum go41 » WordPress Code Snippets

  1. You want to get a jQuery content slider into your WordPress site? If you use the free theme arthemia with a working timthumb script you will find a solution here to display the latest 4 posts in a nice slider based on 'Featured Content Slider Using jQuery' at http://demo.webdeveloperplus.com/featured-content-slider/

    I modified the index.html given to run in WordPress and query the 5 latest posts. The slider is using timthumb to resize images from the custom field 'Image'. Your images should be minimum 610x310px in size to fill the full image space.

    BACKUP YOUR FILES BEFORE EDITING PLEASE!

    A walk through:

    Open and insert in header.php after <?php wp_head(); ?> and before </head> the following lines to include the Javascript we need:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" ></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js" ></script>
    <script type="text/javascript">
    	$(document).ready(function(){
    		   $("#myslider").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
    	});
    </script>

    Open and add to the end of your arthemia theme style.css the following lines:

    /* ui slider css stuff */
    #myslider{
    	width:630px;
    	padding-right:300px;
    	position:relative;
    	border:5px solid #ccc;
    	height:310px;
    	background:#fff;
    }
    #myslider ul.ui-tabs-nav{
    	position:absolute;
    	top:0; left:610px;
    	list-style:none;
    	padding:0; margin:0;
    	width:320px;
    }
    #myslider ul.ui-tabs-nav li{
    	padding:1px 0; padding-left:13px;
    	font-size:12px;
    	color:#666;
    }
    #myslider ul.ui-tabs-nav li img{
    	float:left; margin:2px 5px;
    	background:#fff;
    	padding:2px;
    	border:1px solid #eee;
    }
    #myslider ul.ui-tabs-nav li span{
    	font-size:11px; font-family:Verdana;
    	line-height:18px;
    }
    #myslider li.ui-tabs-nav-item a{
    	display:block;
    	height:75px;
    	color:#333;  background:#fff;
    	line-height:20px;
    }
    #myslider li.ui-tabs-nav-item a:hover{
    	background:#f2f2f2;
    }
    #myslider li.ui-tabs-selected{
    	background:url('images/selected-item.gif') top left no-repeat;
    }
    #myslider ul.ui-tabs-nav li.ui-tabs-selected a{
    	background:#ccc;
    }
    #myslider .ui-tabs-panel{
    	width:610px; height:310px;
    	background:#999; position:relative;
    }
    #myslider .ui-tabs-panel .info{
    	position:absolute;
    	top:240px; left:0;
    	width:610px; height:70px;
    	background: url('images/transparent-bg.png');
    }
    #myslider .info h2{
    	font-size:18px; font-family:Georgia, serif;
    	color:#fff; padding:5px; margin:0;
    	overflow:hidden;
    }
    #myslider .info p{
    	margin:0 5px;
    	font-family:Verdana; font-size:11px;
    	line-height:15px; color:#f0f0f0;
    }
    #myslider .info a{
    	text-decoration:none;
    	color:#fff;
    }
    #myslider .info a:hover{
    	text-decoration:underline;
    }
    #myslider .ui-tabs-hide{
    	display:none;
    }

    copy images for this css classes to your arthemia/images (or themes/images) folder: transparent-bg.png and selected-item.gif
    you get this images on the 'Download source code and try' of the site I gave on top.

    Open up index.php and add under <?php if(!is_paged()) { ?> this:

    <?php if(file_exists(TEMPLATEPATH . '/myslider.php')) {
    include (TEMPLATEPATH . '/myslider.php'); } ?>

    This two lines translate to: if there is a file called myslider.php in the folder of the theme go and use it. As long you didn't create this new template file nothing will happen.

    Remark: this if(!is_paged()) you will find only in arthemias index.php as this theme displays Headline and Featured only on the first page.

    Now we create a file called myslider.php to put into your themes folder with the following content:

    <div id="myslider" >
    	<ul class="ui-tabs-nav">
    		<?php query_posts('showposts=4'); $i = 1; if (have_posts()) { while (have_posts()) { the_post(); ?>
    			<li class="ui-tabs-nav-item <?php if ($i == 1) { ?>ui-tabs-selected<?php } ?>"<?php echo 'id="nav-fragment-' . $i . '"><a href="#fragment-' . $i . '">'; ?>
    			<?php $values = get_post_custom_values("Image"); if (isset($values[0])) { ?>
    				<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=100&h=65&zc=1&q=80" alt="" />
    			<?php } ?>
    			<span><?php the_title(); ?></span></a></li>
    			<?php  $i++; } // end while loop
    			} // end if
    		wp_reset_query(); ?>
    	  </ul>
    	<?php query_posts('showposts=4'); $i = 1; if (have_posts()) { while (have_posts()) { the_post(); ?>
    		<?php echo '<div id="fragment-' . $i . '" class="ui-tabs-panel" style="">'; ?>
    			<?php $values = get_post_custom_values("Image"); if (isset($values[0])) { ?>
    				<a href="<?php the_permalink() ?>" ><img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=610&h=310&zc=1&q=80" alt="" /></a>
    			<?php } ?>
    		<div class="info" >
    				<h2><a href="<?php the_permalink() ?>" ><?php the_title(); ?></a></h2>
    				<p><?php the_content_rss('', TRUE, '', 30);  ?><a href="<?php the_permalink() ?>" >read more</a></p>
    			</div>
    		</div>
    		<?php  $i++; } // end while loop
    		} // end if
    	wp_reset_query(); ?>
    </div>

    As soon you put this file onto your site, you should see something and enjoy.

    Now you could remove the whole headline and featured section from arthemia, I hope you know how to do..

    See a DEMO here: Free WordPress Themes Testrun

    Any questions? -> Create an account and ask!

    Posted 2 years ago #
  2. A new Wordpress theme 'Arthemix Bronze' with this slider on top can be found here:

    Arthemix Bronze Testrun

    Download you can request here or wait for the final version!

    Posted 2 years ago #
  3. teoman
    Member

    hello,
    installed artemix-green but the image slider does not work;
    it does not change pictures and when i change to any of the link on right (#fragment-1 to 4) insted of image change like a new page open and slider disapper.

    what can be wrong ?

    Posted 1 year ago #
  4. cricrazy
    Member

    Hi Joern,

    This is christian from bibleseo.

    is there a way to get rid of side panel in the slider? And instead put Left and right arrows, right inside the main slider (like http://bibleseo.com/biblestudyblog/). This would help bring the sidebar come on the top on a main page. (right side of the slider).

    Posted 1 year ago #
  5. give me some time pls, Joern

    Posted 1 year ago #
  6. @cricrazy
    see the demo here in frontlist beside the sidebat:
    http://themes.go41.de/?wptheme=arthemia

    Is that what you mean?

    I will explain how to get the 'arras slider' in Arthemia soon.

    Posted 1 year ago #
  7. cricrazy
    Member

    Hello masteradmin,

    This is exactly, what I was looking for. Let me know how to achieve it in arthemia.

    Posted 1 year ago #
  8. I opened a new topic 'slideshow using jQuery cycle for WordPress' here:

    http://forum.go41.de/topic/slideshow-using-jquery-cycle-for-wordpress-arthemia

    Hope you can handle it, good luck!

    Posted 1 year ago #
  9. so i have the slideshow working but i am trying to get my header to be over the slideshow. i looked at a similar post and i have tried changing the z-index to the header and all of the tags that came with the myslider but my image still is behind the slider. here is a pic so you can get an idea of what im trying to do i want her fingers to be in front of the slideshow

    http://i193.photobucket.com/albums/z282/derkycollege/header.png

    Posted 1 year ago #
  10. Derky, that's difficult I guess. I wonder how your navbar under her arms is working? As you might have seen, you can bring folding menues in front of the slideshow.
    Actually I would say putting an other image over this would make the menubar not work, am I wrong?
    Your arthemia is not 'live', so it's hard to analyze your theme's css settings-

    Posted 1 year ago #
  11. yep the menubar doenst work under the picture so i planned on having just a link page for home and contact. i may just remove the slideshow from the theme because with it just being a regular headline post the image hangs over it the way i like....thnx anywayz

    Posted 1 year ago #
  12. Kirei
    Member

    Hey there,

    I want to bring this onto my site, but a few things I have a question on.

    1. I don't want my recent posts in the slider. I want only select posts. How can I make it so only those in the "xxyy" catagory will show on the slider?

    2. I actually don't know how to remove the headline/featured section. A link to a tutorial would be nice as I've tried google and it's not helping.

    Thanks :)

    Posted 1 year ago #
  13. to show posts from one category only you have to modify the query, it is in this line:

    <?php query_posts('showposts=4'); $i = 1; if (have_posts()) { while (have_posts()) { the_post(); ?>

    this 'query_posts' needs one more parameter, if you want only a category with the name xxyy it should look like this:

    <?php query_posts('category_name=xxyy&showposts=4'); $i = 1; if (have_posts()) { while (have_posts()) { the_post(); ?>

    even better if you know the ID of the category, than the query for category ID=12 would be:

    <?php query_posts('cat=12&showposts=4'); $i = 1; if (have_posts()) { while (have_posts()) { the_post(); ?>

    before removing the headline and featured section I would insert myslider.php as explained in the first post. That's just two lines modification in index.php.
    If you get this working I will tell you how to remove the other sections.

    good luck

    Posted 1 year ago #
  14. Kirei
    Member

    Hmm didn't work. I created a test site for this. It worked fine, but after I added the cat code it kinda messed up. It's still showing the "new" posts vs just the category. It also isn't showing the correct Featured pictures/posts as it cycles through. The sidebar doesn't match whats being flashed through.

    Test blog here: http://test.gamerofsorts.com/wp/

    Posted 1 year ago #
  15. sorry, didn't think about that:
    The query repeats, it's twice in this script!
    so go through the code and find the second query to modify exactly the same way as the first.

    Anyway, it's running..

    make a backup of index.php and remove the complete div id top to remove headline and featured section if you like.

    you have to delete exactly all this:

    <div id="top" class="clearfloat">
    
    		<div id="headline">
    		<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/headline.png" width="75px" height="21px" alt="" />
    		<?php query_posts("showposts=1&category_name=Headline"); ?>
    		<?php while (have_posts()) : the_post(); ?>	
    
    	<div class="title"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
    	<div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>
    	<?php $values = get_post_custom_values("Headline");?>
     	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=300&h=275&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="300px" height="275px"  /></a>
    	<?php the_excerpt(); ?>
    	<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read the full story &raquo;</a>
    	<?php endwhile; ?>
    		</div>
    
    	<div id="featured">
    
    	<img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/featured.png" width="72px" height="17px" alt="" />
    
    	<?php query_posts("showposts=4&category_name=Featured"); $i = 1; ?>
    
          	<?php while (have_posts()) : the_post(); ?>
    	<div class="clearfloat">
    	<?php $values = get_post_custom_values("Image");
    	if (isset($values[0])) { ?>
          <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
    	<img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
    $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=100&h=65&zc=1&q=100"
    alt="<?php the_title(); ?>" class="left" width="100px" height="65px"  /></a>
          <?php } ?>
    	<div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
    <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]</div>	
    
    </div>
        	</div>
    
          <?php endwhile; ?>
    
    	</div>
    
    </div>

    for testing only you could 'comment' it out, so it's still there but invisible.
    Like this:
    just above <div id="top" class="clearfloat"> add '< ! - -' without spaces, here the code:

    <!-- invisible start
    	<div id="top" class="clearfloat">
    ....

    and below the part to make invisible, that's just above <div id="middle" class="clearfloat">
    you add 'invisible end - - >' (no spaces)
    like this as code:

    </div>
    invisible end -->
    	<div id="middle" class="clearfloat">
    Posted 1 year ago #

RSS feed for this topic

Reply »

You must log in to post.

Join us! or log in (lost password?):