Posted on Leave a comment

Update Custom field in WP

1 Jan – 7 Jan 2014, 1 week, single (£350)
<a href=”?p=450&amp;aimarrivaldate=01/01/2014&amp;aimprice=350#simple-wp-booking-enquiry-form”>Book Now</a>

 

<?php
if($_GET[‘aimprice’]){
  echo ‘<span style=”font-weight:bold; color:red;”>Price: £’ . $_GET[‘aimprice’] . ‘</span>’ ;
  update_post_meta(450, ‘price’, $_GET[‘aimprice’]);
  echo ‘<script type=”text/javascript”> document.getElementById(“arrivaldate”).value=”‘.$_GET[‘aimarrivaldate’].'”; </script>’;
}
?>

Posted on

WordPress Comment/Review form with posts dropdown menu

This is used to for when you need a single form to submit a comment/review by choosing a post from a dropdown menu with all/several posts titles.

1st version shows ALL the posts in the menu and 2nd one allows you to ignore posts from a certain category.

1st version:

<form name=”commentform” action=”wp-comments-post.php” method=”post” id=”commentform”>
<select name=”archive-dropdown” onchange=”var str=this.options[this.selectedIndex].value; document.commentform.comment_post_ID.value = str.substring(str.search(‘p=’)+2);”>
<option value=\”\”><?php echo attribute_escape(__(‘Select Tour’)); ?></option>

<?php wp_get_archives(‘type=postbypost&format=option&show_post_count=0’); ?>

</select>

—————————————

2nd version:

<form name=”commentform” action=”wp-comments-post.php” method=”post” id=”commentform”>
<select name=”archive-dropdown” onchange=”var str=this.options[this.selectedIndex].value; document.commentform.comment_post_ID.value = str.substring(str.search(‘p=’)+2);”>
<option value=\”\”><?php echo attribute_escape(__(‘Select Tour’)); ?></option>

<?php
    $args=array(
      ‘cat’ => -69,
      ‘post_type’ => ‘post’,
      ‘post_status’ => ‘publish’,
      ‘posts_per_page’ => 10,
      ‘caller_get_posts’=> 1
      );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <option value=”<?php the_permalink() ?>”><?php the_title(); ?></option>
       <?php
      endwhile;
    }
  wp_reset_query();  // Restore global post data stomped by the_post().
?>

</select>

&nbsp;<p>Your email address will not be published. Required fields are marked <span>*</span></p>
<p><label for=”author”>Name</label> <span>*</span><input id=”author” name=”author” type=”text” value=”” size=”30″ aria-required=”true” /></p>
<p><label for=”email”>Email</label> <span>*</span>
<input id=”email” name=”email” type=”text” value=”” size=”30″ aria-required=”true” /></p>
<p><label for=”url”>Website</label><input id=”url” name=”url” type=”text” value=”” size=”30″ /></p>
<p><label for=”comment”>Review</label><textarea id=”comment” name=”comment” cols=”45″ rows=”8″ aria-required=”true”></textarea></p>
<p>You may use these <abbr title=”HyperText Markup Language”>HTML</abbr> tags and attributes:  <code>&lt;a href=&quot;&quot; title=&quot;&quot;&gt; &lt;abbr title=&quot;&quot;&gt; &lt;acronym title=&quot;&quot;&gt; &lt;b&gt; &lt;blockquote cite=&quot;&quot;&gt; &lt;cite&gt; &lt;code&gt; &lt;del datetime=&quot;&quot;&gt; &lt;em&gt; &lt;i&gt; &lt;q cite=&quot;&quot;&gt; &lt;strike&gt; &lt;strong&gt; </code></p>
<p>
<input name=”submit” type=”submit” id=”submit” value=”Post Review” />
<input type=”hidden” name=”comment_post_ID” value=”” id=”comment_post_ID” />
<input type=”hidden” name=”comment_parent” id=”comment_parent” value=”0” /></p>
<input type=”hidden” id=”_wp_unfiltered_html_comment” name=”_wp_unfiltered_html_comment” value=”8b42defd9a” />
<p style=”display: none;”>
<input type=”hidden” id=”akismet_comment_nonce” name=”akismet_comment_nonce” value=”b3ef566a7d” />
</p>
</form>

—————————-

To just display a list of these posts instead of options in a form, use this code:

<?php
    $args=array(
      'cat' => -3,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      'caller_get_posts'=> 1
      );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of 5 Posts but excluding category id 3';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
       <?php
      endwhile;
    }
  wp_reset_query();  // Restore global post data stomped by the_post().
?>