September 27, 201016 yr Morning all, With much help from Welshuw (Thanks Huw) we've managed to add this rotating image (where main image was) I need to be able to put diff changing images on diff pages, neither of us can suss this out - I did come up with an an idea that seemed logical, but it didnt work Can anyone help? Am willing to pay for help.... Thanks in advance Gem
September 27, 201016 yr Depending on how you plan on using wordpress there are a few ways. Firstly you could create a page template for each page, and staticly add the specific image for each page template. If you plan on keeping one template, you could use custom fields with specific id's and add the code to your template. Thirdly, you could use custom metaboxes. Similar idea to the one previously.
September 27, 201016 yr Author Im really quite new to WP, which of your options would you suggest is easiest? Welshuw hard coded the Nivo slider for me, to get it doing what it is now. Thanks Gem
September 27, 201016 yr Easiest is the first option, all you would do is copy the exising template and change the template nane, add new the images in the html. In the wordpress admin you would select the new template when creating a new page. Although the easiet, its not very CMS friendly. If you needed to make a new page, you would have to upload a new page template each time you needed to change the images.
September 27, 201016 yr I would suggest the custom fields method asek has outlined. 1. In WP Admin go to pages. 2. Select a page and click edit 3. Just under the WYSIWYG editor there's a custom fields area 4. Click 'Enter New' 5. Type 'slider' into the name and all of the images HTML into the content field. For an example of the content field, fill it with this (from your homepage): <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f1.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f2.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f3.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f4.jpg" title="" /> 6. Now click 'Add custom field' and update the page (save it) 7. Open up your page template file (usually page.php) 8. Find this code: <div id="slider">....all the image code...</div> 9. Remove the whole slider div and replace it with this: <?php $custom = get_post_custom(); if ($custom['slider']) echo "<div id=\"slider\">".$custom['slider'][0]."</div>"; ?> 10. Save that file and upload 11. Now repeat steps 2-6 for each page you want a slider on. When adding the custom field, use the pre-saved 'slider' one and use different image code in the content field to show different images on that page. Hope it works - just written now and untested! Edit: changed the code a little bit so the slider div is only shown if you've added a custom field - avoids wasted code/whitespace on the page depending on your CSS.
September 27, 201016 yr Author Thanks for your help, both of you - Ill give it a go and let you now how I get on Thanks again Gem
September 27, 201016 yr Nice one andy! My easiest idea was to use different template files. But making it more 'CMS' friendly is an awesome idea.....
September 27, 201016 yr Author I cant see the <div id="slider">....all the image code...</div> in the page.php - but it is in the header.php - should I change it there? Thanks Gem
September 27, 201016 yr I cant see the <div id="slider">....all the image code...</div> in the page.php - but it is in the header.php - should I change it there? Thanks Gem Yeah, change it in the header.php file.
September 27, 201016 yr Author Oh, now the pic has gone....what did I blow up? My header.php looks like this now <?php /** * The Header for our theme. * * Displays all of the <head> section and everything up till <div id="main"> * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ ?><!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo( 'charset' ); ?>" /> <title><?php /* * Print the <title> tag based on what is being viewed. */ global $page, $paged; wp_title( '|', true, 'right' ); // Add the blog name. bloginfo( 'name' ); // Add the blog description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) echo " | $site_description"; // Add a page number if necessary: if ( $paged >= 2 || $page >= 2 ) echo ' | ' . sprintf( __( 'Page %s', 'twentyten' ), max( $paged, $page ) ); ?></title> <link rel="profile" href="http://gmpg.org/xfn/11" /> <link rel="stylesheet" type="text/css" media="all" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery.nivo.slider.pack.js"></script> <link rel="stylesheet" type="text/css" media="all" href="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/css/nivo-slider.css" /> <link rel="stylesheet" type="text/css" media="all" href="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/css/custom-nivo-slider.css" /> <script type="text/javascript"> $(window).load(function() { $('#slider').nivoSlider(); }); </script> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" /> <?php /* We add some JavaScript to pages with the comment form * to support sites with threaded comments (when in use). */ if ( is_singular() && get_option( 'thread_comments' ) ) wp_enqueue_script( 'comment-reply' ); /* Always have wp_head() just before the closing </head> * tag of your theme, or you will break many plugins, which * generally use this hook to add elements to <head> such * as styles, scripts, and meta tags. */ wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="wrapper" class="hfeed"> <div id="header"> <div id="masthead"> <a href="/"><img src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/headers/logo.jpg" width="940" height="100" alt="" /></a> <div id="branding" role="banner"> <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?> <<?php echo $heading_tag; ?> id="site-title"> <span> <a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a> </span> </<?php echo $heading_tag; ?>> <div id="access" role="navigation"> <?php /* Allow screen readers / text browsers to skip the navigation menu and get right to the good stuff */ ?> <div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div> <?php /* Our navigation menu. If one isn't filled out, wp_nav_menu falls back to wp_page_menu. The menu assiged to the primary position is the one used. If none is assigned, the menu with the lowest ID is used. */ ?> <?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?> </div><!-- #access --> <?php $custom = get_post_custom(); if ($custom['slider']) echo "<div id=\"slider\">".$custom['slider'][0]."</div>"; ?> </div><!-- #branding --> </div><!-- #masthead --> </div><!-- #header --> <div id="main"> and Ive added the custom field as described above.... Thanks
September 27, 201016 yr It won't work if it's in header.php as the page global has not yet been set. You'll need to move the code I supplied into your page.php file inside the main loop (as demo'd below) - completely remove it from your header.php file: ....little bit of code here.... <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $custom = get_post_custom(); if ($custom['slider']) echo "<div id=\"slider\">".$custom['slider'][0]."</div>"; ?> ....little bit of code here....
September 28, 201016 yr Author Thanks for all your help on this Andyl! Ok, so I have: 1. In the Wordpress Admin area, gone into the home page and under 'Custom Fields' I have added 'slider' in the Name Field and Ive added <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f1.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f2.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f3.jpg" title="" /> <img alt="" src="http://www.sussexwebsitedesign.net/testwp/wp-content/themes/twentyten/images/f4.jpg" title="" /> into the Value Field and updated. In page.php Ive added the code you mentioned (Ive bolded it on here): <?php /** * The template for displaying all pages. * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages * and that other 'pages' on your WordPress site will use a * different template. * * @package WordPress * @subpackage Twenty_Ten * @since Twenty Ten 1.0 */ get_header(); ?> <div id="container"> <div id="content" role="main"> <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> [b]<?php $custom = get_post_custom(); if ($custom['slider']) echo "<div id=\"slider\">".$custom['slider'][0]."</div>"; ?>[/b] <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php if ( is_front_page() ) { ?> <h2 class="entry-title"><?php the_title(); ?></h2> <?php } else { ?> <h1 class="entry-title"><?php the_title(); ?></h1> <?php } ?> <div class="entry-content"> <?php the_content(); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> <?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?> </div><!-- .entry-content --> </div><!-- #post-## --> <?php comments_template( '', true ); ?> <?php endwhile; ?> </div><!-- #content --> </div><!-- #container --> <?php get_sidebar(); ?> <?php get_footer(); ?> [/code And its still not showing.... Any other ideas? Thanks again, Gem x
September 28, 201016 yr Ok take out this line: if ($custom['slider']) Let me know when you've uploaded the changes - you'll hopefully see some error code.
September 28, 201016 yr Author Ok, I took it out, and the main image looks squashed http://sussexwebsitedesign.net/testwp/ Thanks Gem
September 28, 201016 yr Well the template file you edited isn't being used to render the page then. There should be at least <div id="slider"></div> in the code now because there's no conditional for it, but there's no sign of it. Do you know what template file is called for pages on your theme? Add my code to that file instead. I don't think it's my code that's the problem, it's the file you've put it in!
September 28, 201016 yr Author Well the template file you edited isn't being used to render the page then. There should be at least <div id="slider"></div> in the code now because there's no conditional for it, but there's no sign of it. Do you know what template file is called for pages on your theme? Add my code to that file instead. I don't think it's my code that's the problem, it's the file you've put it in! Oh....I am a newbie to WP and Im not sure what the template file is called. Does the attached shed any light? Thanks Gem
September 29, 201016 yr Try adding the same code to the 'onecolumn-page.php' file (in the same position I described) see if that's the one in use. No problem
September 29, 201016 yr Author Ok Cool, its appearing, but the image at the tops has been squashed, and the slider itself is small.... Thanks Gem
September 29, 201016 yr Author I also added in the line we took out earlier (bolded) so it now looks like.... <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <?php $custom = get_post_custom(); if ($custom['slider']) echo "<div id=\"slider\">".$custom['slider'][0]."</div>"; ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
September 29, 201016 yr Ok Cool, its appearing, but the image at the tops has been squashed, and the slider itself is small.... Thanks Gem if the image is squashed then it's a css problem... look in your css for #slider img (if not there add it, and set the height of the image)
September 29, 201016 yr Author if the image is squashed then it's a css problem... look in your css for #slider img (if not there add it, and set the height of the image) Its not the slider image (although that is pretty weeny) The logobar at the top used to be 100 px.... http://sussexwebsitedesign.net/testwp/ Thanks for replying
September 29, 201016 yr Both of those will likely be a CSS problem, very unlikely to be linked with my code.
Create an account or sign in to comment