rjpinney
Forum Replies Created
-
Forum: Themes and Templates
In reply to: Get post meta WITH formatting?I’m using the advanced custom fields plugin, which provides a full text editor – if I set the style to ‘heading 6’ for example, it will render line breaks.
I saw somewhere a very brief comment on a similar issue which said that if you use the get_post_meta command, it will strip out formatting, but that there was an alternative way of retrieving the info that might also reflect the formatting?
Forum: Plugins
In reply to: Basic PHP variable problem – custom fieldsThanks for your reply!
This is the loop code I have so far, which adds a prefix to each entry depending on its category:
<?php query_posts('post_type=event&meta_key=date&orderby=meta_value&order=ASC'); ?> <?php while (have_posts()) : the_post(); ?> <li style="list-style:none"> > <?php if ( get_post_meta($post->ID, 'book_launch', true) ) : ?>Book Launch: <?php endif; ?> <?php if ( get_post_meta($post->ID, 'book_signing', true) ) : ?>Book Signing: <?php endif; ?> <?php if ( get_post_meta($post->ID, 'media_appearance', true) ) : ?>Media Appearance: <?php endif; ?> <?php if ( get_post_meta($post->ID, 'public_lecture', true) ) : ?>Public Lecture: <?php endif; ?> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> / <?php echo get_post_meta($post->ID, 'date', true); ?> </li> <?php endwhile; ?>
The custom field for the date is called ‘date’ (the loop is currently ordered by that) and its output format is currently yy mm dd, for sorting reasons, though this can be changed.
Thanks
Rob
Forum: Themes and Templates
In reply to: Loop a category from a custom post typeThat did the trick, thanks!
Forum: Fixing WordPress
In reply to: Next/Previous page not working on custom pageNow fixed, answer was here:
https://www.ads-software.com/support/topic/posts_nav_link-now-wont-show-up?replies=14
Forum: Themes and Templates
In reply to: Tabs in page templateHave now sorted this
Forum: Themes and Templates
In reply to: Adding 'The Loop' into tabs – problem with jQuery/CSS3?Can post the CSS for the loop styling if needed
Forum: Themes and Templates
In reply to: Adding 'The Loop' into tabs – problem with jQuery/CSS3?I should also add that the loop code also works when used on its own.
Thanks!
Forum: Themes and Templates
In reply to: Showing post title as overlay on featured image on hoverThat’s done the job perfectly, thank you for your swift reply!
The only problem is that the opacity overlay is on top of the text so there is little contrast between them making it very difficult to read!
Forum: Fixing WordPress
In reply to: Issues with HTML/PHP contact formThanks for the link, unfortunately I think it may have been slightly above my head.
I have managed to get it to direct to a URL when the form has been successfully completed, which is half the battle. What I now want it to do is direct to a different URL when the form validation is declined.
From what I can figure out, the middle section of the code pasted below is the validation of what the user has put in to the HTML form on the site. When that comes back negative, it gives a plain text ‘We are sorry etc’ message, as coded at the top part of the form. What I want to have is for it to go to hurstblog.co.uk/contact-error instead.
If you have any pointers on this it would be much appreciated, I can’t seem to find the answer in any tutorials and im very new to PHP!
<?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_subject = "HurstBlog Contact Message"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> <?php { header("Location: https://hurstblog.co.uk/contact-thanks"); } ?> <?php } ?>
Forum: Fixing WordPress
In reply to: Issues with HTML/PHP contact formNow that the script is running correctly, I have run into another problem – Instead of the script (copied below) showing up a plain text page with either the appropriate error message or the success message, I want it to redirect to a page I have set up on my blog. (EG: For invalid details, redirect to a page that says there was a problem and for success, to a thanks page).
This is some stock code from a tutorial, but is working – do you know what the command would be to direct to a URL?
Thanks!
<?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "[email protected]"; $email_subject = "HurstBlog Contact Message"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?>
Forum: Fixing WordPress
In reply to: Issues with HTML/PHP contact formJust managed to get it work, finally! I’m not actually sure what changed, but it suddenly decided to work with /mailform.php
Thanks again
Forum: Fixing WordPress
In reply to: Issues with HTML/PHP contact formHi Brad,
Yes – I’m trying to limit the number of active plugins on the site, and find that coding things (usually by trial and error) is a good way of picking it up.
I’ll have another go at the form, but no luck as yet.
Thanks for your help!
I am having a similar problem – plugin seems great, something clean and simple, but I can’t find – anywhere – the option to change the match threshold. There is no relatedness option on Screen Options, is this owing to the recent wordpress upgrade? (which I am using…)
Also, could you let me know whether YARPP excludes the post from which you have come by default, or whether this is owing to a match threshold problem?
Thanks!
Forum: Fixing WordPress
In reply to: Issues with HTML/PHP contact formHi Brad,
Thanks for the reply.
I’ve taken the script down so can’t point to a live example im afraid. I think the issue is with where the browser is looking for the PHP script, as you said – do you know exactly where I should upload this file? (ie: under the particular theme on FTP etc?)