Jump to content

Jezthomp

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Everything posted by Jezthomp

  1. Hello Alt, I'm not sure if your around but i need a hand with your code. Currently it only is show 24 posts, i need it to be unlimited or even better have another page link to show the rest of the posts. i.e no limit to the amount shown.. Any help would be much appreciated. Many thanks
  2. I have various pages with multiple loops and i need them to be individual to all other categories. 2 columns. Left column shows 4 posts from category news just with the date and some custom information. Right column, on the home page shows the latest post and every other page shows the post content from the one you have just clicked on in the left column, all the full post content appears there, with the left column still showing the latest posts still. These two elements need to ignore all other categories and posts. I have been using this multiple loop code, on both the news page and single page. <?php /** * @package WordPress * @subpackage Starkers */ get_header(); ?> <?php get_sidebar(); ?> <div id="grid_2"> <div id="news_links"> <ul> // Get the last 3 posts in the featured category. <?php query_posts('category_name=news&showposts=4'); ?> <?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true );?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> <span> <li><?php the_time('F jS, Y') ?></li> <li><?php the_title(); ?></li> <li><?php echo $data[ 'place' ]; ?></li> <li><?php echo $data[ 'location' ]; ?></li> </span> </a> <?php endwhile ?> </ul> </div> <!--news_links--> <div class="clearFix"><!--x--></div> </div> <!--grid_2--> //We reset the loop <?php rewind_posts(); ?> <div id="grid_3"> <?php if (have_posts()) : ?> <?php query_posts('category_name=news&showposts=1'); ?> <?php while (have_posts()) : the_post(); ?> <div <?php post_class() ?> id="post-<?php the_ID(); ?>"> <h2><?php the_title(); ?></h2> <?php the_content('Read the rest of this entry »'); ?> <p><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p> </div> <?php endwhile; ?> <?php next_posts_link('« Older Entries') ?> | <?php previous_posts_link('Newer Entries »') ?> <?php else : ?> <h2>Not Found</h2> <p>Sorry, but you are looking for something that isn't here.</p> <?php get_search_form(); ?> <?php endif; ?> <div class="clearFix"><!--x--></div> </div> <!--grid_3--> The problem i have is that regardless of which post you click on in the left column it always shows the same post in the right column, the most recent one, not the one you have just clicked on! I think its something to do with this.. <?php query_posts('category_name=news&showposts=1'); ?> As its been told to show 1 post and its showing the most recent one. Any idea how i can get it to show just the post you have clicked on in the right column?
  3. Sorted myself with the aid of this tutorial and this bit of code. <?php if (have_posts()) : while (have_posts()) : the_post(); if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?> My second loop was repeating the first one, not showing its own, so i found that added ...and it then printed its own and ignored the first one. Woooo Hoooo
  4. I have the following code which is meant to have 3 loops in it, top middle and bottom. However, when viewed its all broken and not displaying right. <?php /* Single Post Template: Event Detail Description: Main page for final drill down of event! */ ?> <?php get_header(); ?> <ul class="banner_ad"> <?php query_posts('cat=14'); ?> <?php while (have_posts()) : the_post(); ?> <li><?php the_content(); ?></li> <?php endwhile;?> </ul> <?php rewind_posts(); ?> <!--end first Loop?--> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true ); ?> <div id="detail_holder"> <div id="detail_image"> <img src="http://jezthompson.co.uk/ransom_note/wp-content/uploads/<?php echo $data[ 'event_image' ]; ?>" alt = "work image"/> </div> <!--detail_image--> <div id="detail_right"> <?php $content = split("<!--more-->", $post->post_content);?> <div id="detail_right_title"> <div id="detail_holder_inner_cat<?php $category = get_the_category(); echo $category[0]->cat_ID;?>"> <ul> <li><?php the_title(); ?></li> <li><?php echo $data[ 'event_date' ]; ?> </li> <li><?php echo $data[ 'event_location' ]; ?> » <?php echo $data[ 'event_time' ]; ?></li> </ul> </div> <!--detail_holder_inner--> </div> <!--detail_right_title--> <div class="content_box"> <?php echo apply_filters('the_content', $content[0]); ?> <?php echo apply_filters('the_content', $content[1]); ?> </div> <!--text content--> <div class="content_box"> <p><a href="mailto:blank?body=The article '<?php the_title(); ?>' has been sent to you. You can view it at: <?php the_permalink() ?>" title="E-mail this item to a friend">Send to a friend</a></p> </div> <!--send to friend--> <div class="content_box"> <?php echo apply_filters('the_content', $content[2]); ?> </div> <!--links--> <div class="content_box"> <ul class="prev_nxt"> <li class="jFlowPrev"><?php previous_post_link('« %link') ?></li> <li class="jFlowNext"><?php next_post_link('%link »') ?></li> </ul> </div> <!--next/previous--> <?php endwhile; ?> <?php endif; ?> <div class="clearFix"><!--x--></div> </div> <!--detail_right--> <div class="clearFix"><!--x--></div> </div> <!--detail_holder--> <?php rewind_posts(); ?> <!--end middle Loop--> <ul class="lowerbanner"> <?php query_posts('cat=11'); ?> <?php while (have_posts()) : the_post(); ?> <li><?php the_content(); ?></li> <?php endwhile;?> </ul> <?php get_footer(); ?> I dont understand as i've used the 3 loops on other pages, with only the centre one changing on this page its messed it all up. Any ideas?
  5. Yeah i'm using that bit of code. From my experience with WP that should take any posts from the selected cats and print them however many, not limiting it to any fixed amount, which is what i am after. What you have done certainly makes sense, whether i could do it again on my own would be another matter, i'll go through it step by step, the comments certainly help also. Many thanks again
  6. Perfect!!! Brilliant, thank you so much You're a legend!
  7. Yes of course sorry... Your code page.. How it currently is, which is fine apart from the big white empty div.example at the bottom as discussed.
  8. Thanks Alt that is working great, its just the content inside the li's which is going abit wonky. The permalink's are working as they should, the image and the read more work as links on their own, however above each one it is printing the full link in text as well, literally printing the http:// bit... Also in a similar way the h3 text is appearing but above out of its h3 holder for some reason.. Any idea?
  9. Thanks again Feel its so close another rubbish error though.. Which is this like i think.. echo '<p>.'$data[ 'event_time' ].'</p>';
  10. Thanks again, Alt. Getting an a little error though... Which is this line.. echo '<a href="'.the_permalink().'" title="View more details of '.the_title();.'"><img src="wp-content/uploads/'; echo $data[ 'event_image' ].'" alt = "work image"/></a>';
  11. That works apart from the line appears in the final div.example. I'll also need this in the li tags.. <li class="cat<?php $category = get_the_category(); echo $category[0]->cat_ID;?>"> <a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>"><img src="wp-content/uploads/<?php echo $data[ 'event_image' ]; ?>" alt = "work image"/></a> <h3><?php the_title(); ?></h3> <p><?php echo $data[ 'event_date' ]; ?></p> <p><?php echo $data[ 'event_location' ]; ?></p> <p><?php echo $data[ 'event_time' ]; ?></p> <p><a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>">Read More</a></p> <div class="clearFix"><!--x--></div> </li> Which the above doesn't like..
  12. Unfortunately no, it just needs to show all the posts from category 3,4,5 and 6. Thank you for your code but its still repeating the empty div.example at the bottom Also the li column has to have the following code in it, which wouldnt work either.. <li class="cat<?php $category = get_the_category(); echo $category[0]->cat_ID;?>"> <a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>"><img src="http://jezthompson.co.uk/ransom_note/wp-content/uploads/<?php echo $data[ 'event_image' ]; ?>" alt = "work image"/></a> <h3><?php the_title(); ?></h3> <p><?php echo $data[ 'event_date' ]; ?></p> <p><?php echo $data[ 'event_location' ]; ?></p> <p><?php echo $data[ 'event_time' ]; ?></p> <p><a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>">Read More</a></p> <div class="clearFix"><!--x--></div> </li> So my final one looks like this.. <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; $postcnt = 0; query_posts('cat=3,4,5,6'); if (have_posts()) { ?> <div class="example"> <ul class="content_cols"> <?php while ( have_posts() ) : the_post(); $postcnt++; $data = get_post_meta( $post->ID, 'key', true );?> <li class="cat<?php $category = get_the_category(); echo $category[0]->cat_ID;?>"> <a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>"><img src="http://jezthompson.co.uk/ransom_note/wp-content/uploads/<?php echo $data[ 'event_image' ]; ?>" alt = "work image"/></a> <h3><?php the_title(); ?></h3> <p><?php echo $data[ 'event_date' ]; ?></p> <p><?php echo $data[ 'event_location' ]; ?></p> <p><?php echo $data[ 'event_time' ]; ?></p> <p><a href="<?php the_permalink() ?>" title="View more details of <?php the_title(); ?>">Read More</a></p> <div class="clearFix"><!--x--></div> </li> <?php if($postcnt % 2 == 0) { ?> <?php if($postcnt % 6 == 0) { ?> </ul> <div class="line"></div> <div class="clearFix"><!--x--></div> </div> <div class="example"> <?php } ?> <ul class="content_cols"> <?php } ?> <?php endwhile; ?> </ul> <div class="clearFix"><!--x--></div> </div> <?php } ?> Sorry i didn't think it would have any baring on things... Still strange how your code shows the empty div.example also, perhaps it just wont work at all
  13. No not really, i dont think. If there has to be a set amount of posts then i'll have to grin and bear it, i was hoping that it could work without needing it as the post count might be more or less than it is now... <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; $postcnt = 0; query_posts('cat=3,4,5,6'); if (have_posts()) { ?> <div class="example"> <ul class="content_cols"> <?php while ( have_posts() ) : the_post(); $postcnt++; $data = get_post_meta( $post->ID, 'key', true );?> <li> li col here </li> <?php if($postcnt % 2 == 0) { ?> <?php if($postcnt % 6 == 0) { ?> </ul> <div class="line"></div> <div class="clearFix"><!--x--></div> </div> <div class="example"> <?php } ?> <ul class="content_cols"> <?php } ?> <?php endwhile; ?> </ul> <div class="clearFix"><!--x--></div> </div> <?php } ?> The most important thing is the final div.example doesn't display the <div class="line"></div> hence the bottom of the rows, the line appears in all the above rows as its separator. Its why i didn't include it in the end part of the code the final div.example. Many thanks for you help
  14. i'm not entirely sure, as i said i've pieced it together from tutorials and reading things, it probably works without it, i wasn't sure though. Basically, as each row has 6 columns of li's in it i thought it might be needed for a multiple of 2, i.e 6. Its all working well, until you get to the end and as you say it prints the extra empty div.example which is obviously not what i'm after as no posts are in it... If i added a post it would look fine, but need it to be dynamic to the available content and not hope its never an even 24 as you'll get a big space
  15. Yeah that is correct, is there anyway to tell it that if there is no more list items to publish it just closes and finishes its job. I couldn't figure it out i must have moved things around so many times with no luck I'm not the greatest with these things anyway, i've pieced it together from bits and bobs and got lucky really.
  16. I have been using this code to show div.example with 6 li columns inside it, each li is a post with its info inside. Once it gets to the 6th li it closes the div.example and starts a new one. This to enable me to divide them with a dotted line. However, when it gets to the 4th row it prints an empty div.example because there are no li's to go in it, i just need it to stop once it gets to 24, now its stopping at 24 but printing one final div.example... Really i need it to stop when there is no more li's to show, which it does however its printing this extra div.example and i dont know why. :'( You can see it here the big gap at the bottom is another div.example its showing with nothing inside it! (only part of the whole page code as its the only bit that is not working correctly and isn't connected to anything else.) <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; $postcnt = 0; query_posts('cat=3,4,5,6'); if (have_posts()) { ?> <div class="example"> <ul class="content_cols"> <?php while ( have_posts() ) : the_post(); $postcnt++; $data = get_post_meta( $post->ID, 'key', true );?> <li> column here </li> <?php if($postcnt % 2 == 0) { ?> <?php if($postcnt % 6 == 0) { ?> </ul> <div class="line"></div> <div class="clearFix"><!--x--></div> </div> <div class="example"> <?php } ?> <ul class="content_cols"> <?php } ?> <?php endwhile; ?> </ul> <div class="clearFix"><!--x--></div> </div> <?php } ?> The forum doesn't seem to be showing the first postcnt code properly, its the same as the one below just with 2 rather than 6 Any ideas? Obviously very annoying as dont want that final div.example there at all as nothing is in it!! Many thanks for any help
  17. I have defined it here.... div#pageNumbers a:hover, #pageNumbers a:focus, #pageNumbers a:active,#pageNumbers a.selected{ color: Purple; } With help i have managed to crack the problem with the below working fine now <?php function classChange($page,$class){ if(stristr($_SERVER['PHP_SELF'],$page)){ return 'class="'.$class.'"'; } } ?> <div id="pageNumbers"> <p><a href="/Recent/Vietnamsp.php" <? echo classChange('Recent/Vietnamsp.php','selected'); ?>>1</a> </div> Thanks for all your help
  18. Thanks for that, i'm sorry if i am being dumb here but that seems to be more complicated than the one that should work but doesn't. Does it work for yourself, i understand that more than yours. I just dont understand why its not working I wanted to still control the link and the active style with the css style sheet and just have an include for the nav itself. Thanks again
  19. Hello i wonder if anyone could help me with this little but essentially very useful problem? At the moment i currently use a simple include php script. <?php require_once('includes/Nav.php'); ?> For the usual reason of when the site gets big i only need to change 1 file. However, i now need to include a navigation which also has a a:active style on it, i.e when on that page it tells you with the style. Is there anyway i can still include this navigation, i cannot think of how to do it because the file will be the same on every page so how will it know its active? I asked on another forum where someone was kind enough to help me and we came up with the following...but it doesn't work. With one home page. testHome.php one include testInc.php and another page test1.php to link to. Both the testHome and test1 have the testInc however, when you click between them nothing happens. I popped it online here and the code is as follows.... testInc.php <?php function classChange($page,$class){ if(stristr($_SERVER['REQUEST_URI'],$page)){ return 'class="'.$class.'"'; } } ?> <div id="pageNumbers"> <p><a href="/testHome.php" <? echo classChange('/testHome','selected'); ?>>test1</a> <a href="/test1.php" <? echo classChange('/test1.php','selected'); ?>>test2</a> </p> </div> testHome and test1.. <title>Untitled Document</title> <link href="styles/master.css" rel="stylesheet" type="text/css" /> </head> <body> <?php require_once('includes/testInc.php'); ?> Test 1 </body> </html> and just incase the css... div#pageNumbers a{ color: Black; text-decoration: none; } div#pageNumbers a:hover, #pageNumbers a:focus, #pageNumbers a:active, #pageNumbers a.selected{ color: Purple; } It just doesn't work, the link doesn't remain purple when on the appropriate page! Any ideas?
  20. I have the following form <div id="emailContainer"> <?php ini_set("sendmail_from", "mailserver@********.co.uk"); if ($_POST["Submit"]) { // if we dont have all the info we want then we will output an error message if ((!$_POST["name"]) OR (!$_POST["email"])) { // We do not have all the info we need so output error print "<br>You have not given us all the information we need to process the form.<br>"; print "Please use the browser back and/or refresh button to go back and edit the form."; }else{ // We have the info we need so lets send the info in an email $recipient = "Website Enquiry <[email protected]>"; $subject = "Evacuee Website Enquiry Form"; // Lets get all the info from the form and so we can send it in the email $name = $_POST["name"]; $telNum = $_POST["telNum"]; $email = $_POST["email"]; $comments = $_POST["comments"]; $message = "WEBSITE CONTACT FORM: ____________________________________________ Contact Info: Name: $name E-Mail Address: $email Contact No: $telNum ____________________________________________ Comments: Comments: $comments "; $extra = "From: $name <$email>"; // actually send the mail mail ($recipient, $subject, $message, $extra); // Print thank you message print "Many Thanks $name! for contacting us, we shall get back to you as soon as possible..."; } } else { ?> <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" name="form1"> <fieldset> <legend>Please fill out the form below for any further enquiries. TESTING </legend> <div class="field"> <label for="name">Name: <span class="required">*</span></label> <input class="text" id="name" maxlength="64" name="name" size="24"type="text"/> </div> <div class="field"> <label for="email">Email Address: <span class="required">*</span></label> <input class="text" id="email" name="email" size="32"type="text"/> </div> <div class="field"> <label for="telNum"><span>Tel No:</span></label> <input name="telNum" class="text" id="telNum"size="32" type="text"/> </div> <div class="field"> <label for="comments"><span>Comments:</span></label> <textarea name="comments" cols="31" rows="5" class="text" id="comments"></textarea> </div> <div class="field"> <input name="Submit" type="submit" class="submit" value="Submit" /> </div> </fieldset> <div></div> </form> <?php } ?> </div> Now it works on this site phpinfo which has PHP Version 4.3.2 on it However, i am using the same form on another site and its not workingphpinfo which has PHP Version 4.4.4 on it. The form sends ok and you get the confirmation line but the email is not delivered. I have been scratching my head over this one for a while, any ideas anyone? Many thanks
  21. That doesn't work Robin Thankyou anyway.
  22. Recently i have noticed that a form template i have been using is not checking whether certain fields are not filled in and just posting the form regardless. <?php ini_set("sendmail_from", "mailserver@*******.co.uk"); if ($_POST["formName"] == "contactForm") { if (($_POST["name"] == "") OR ($_POST["email"] == "") OR ($_POST["telNum"] == "")) { print "<br>You have not given us all the information we need to process the form.<br>"; print "Please use the browser back and/or refresh button to go back and edit the form."; }else{ $recipient = "Enquiries <[email protected]>"; $subject = "Website Enquiry Form"; $name = $_POST["name"]; $telNum = $_POST["telNum"]; $email = $_POST["email"]; $website = $_POST["website"]; $comments = $_POST["comments"]; $message = "WEBSITE CONTACT FORM: ____________________________________________ Contact Info: Name: $name E-Mail Address: $email Contact No: $telNum There Website: $website ____________________________________________ Comments: Comments: $comments "; $extra = "From: $name <$email>"; mail ($recipient, $subject, $message, $extra); print "Many Thanks $name! for contacting us, we shall get back to you as soon as possible..."; } } else { ?> <form action="<?php print $_SERVER['PHP_SELF']; ?>" method="post" name="contactForm"> <fieldset> <legend>Enquiry Form </legend> <div class="fieldContact"> <label for="name">Name: <span class="required" title="This field is required.">*</span></label> <input class="text" id="name" maxlength="64" name="name" size="24" title="Enter name here" value="Enter name here"onfocus="if (this.value == this.defaultValue) this.value = ''" onblur="if (!this.value) this.value=this.defaultValue" type="text"/> </div> <div class="fieldContact"> <label for="email">Email Address: <span class="required" title="This field is required.">*</span></label> <input class="text" id="email" name="email" size="32" title="Enter email address here" value="Enter email address here" onfocus="if (this.value == this.defaultValue) this.value = ''" onblur="if (!this.value) this.value=this.defaultValue"type="text"/> </div> <div class="fieldContact"> <label for="telNum">Tel No:<span class="required" title="This field is required.">*</span></label> <input name="telNum" class="text" id="telNum" title="Enter telephone number here" value="Enter telephone number here"onfocus="if (this.value == this.defaultValue) this.value = ''" onblur="if (!this.value) this.value=this.defaultValue" size="32" type="text"/> </div> <div class="fieldContact"> <label for="comments"><span>Comments:</span></label> <textarea name="comments" cols="25" rows="5" class="text" id="comments"></textarea> </div> </fieldset> <div><input name="Submit" type="submit" class="submit" value="Submit" /><input name="formName" type="hidden" id="formName" value="contactForm" /></div> </form> <?php } ?> Is suddenly not working when it used too This is an older form i used and it works in regard to checking the fields, the only difference is the one that doesnt work is a css form. <?php ini_set("sendmail_from", "mailserver@********.net"); if ($_POST["Submit"]) { if ((!$_POST["name"]) OR (!$_POST["telNum"]) OR (!$_POST["email"])) { print "<br>You have not given us all the information we need to process the form.<br>"; print "Please use the browser back and/or refresh button to go back and edit the form."; }else{ $recipient = "Enquiries <enquiries@*******.net>"; $subject = "Website Enquiry Form"; $name = $_POST["name"]; $company = $_POST["company"]; $telNum = $_POST["telNum"]; $email = $_POST["email"]; $message = $_POST["message"]; $message = "WEBSITE CONTACT FORM: ____________________________________________ PERSONAL INFO: Name: $name Company: $company Contact No: $telNum E-Mail Address: $email ____________________________________________ MESSAGE: Message: $message "; $extra = "From: $name <$email>"; mail ($recipient, $subject, $message, $extra); print "Many Thanks $name! for contacting us, we shall get back to you as soon as possible..."; } } else { ?><form action="http://www.***********.net/contact.php" method="post" name="form1"> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td width="61%" class="formTitles">Name:</td> </tr> <tr> <td><input name="name" type="text" class="formInformation" id="name" size="45" /></td> </tr> <tr> <td class="formTitles">Company:</td> </tr> <tr> <td><input name="company" type="text" class="formInformation" id="company" size="45" /></td> </tr> <tr> <td class="formTitles">Contact No: </td> </tr> <tr> <td><input name="telNum" type="text" class="formInformation" id="telNum" size="45" /></td> </tr> <tr> <td class="formTitles">Email:</td> </tr> <tr> <td><input name="email" type="text" class="formInformation" id="email" size="45" /></td> </tr> </table> <br /> <table width="100%" border="0" cellspacing="5" cellpadding="0"> <tr> <td class="formTitles">What would you like to know? </td> </tr> <tr> <td><textarea name="message" cols="45" rows="5" class="formInformation" id="message"></textarea></td> </tr> <tr> <td><input name="Submit" type="submit" class="submit" value="Submit" /></td> </tr></table> </form> <?php } ?> I'm no php wizard and a friend of mine did it on this form for me, so i have no idea why its doing it, the form is sending fine just whether the fields are filled in or not. I'm worrying this could leave it open to spam attacks anything i can add to to help that as well? Many thanks for any help, i'm sure i am being blind or something. Cheers
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.