• Dear All,

    I’m implementing a simple facebox code into a WP loop on archive page and I have a quick contact form in that facebox, This facebox opens with the click of a send enquiry button placed within the each loop entry. I want to pick the title of that particular entry into a form label so that it get mailed to me along with the form submission. I’ve tried the simple title function <?php the_title(); ?> but it shows the title of first entry in the loop every time, What I’ve implemented is

    <?php if (have_posts()) : ?>
    	<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    
    		<?php /* If this is a category archive */ if (is_category()) { ?>
    		<h2 class="page-title">All Properties Under <?php single_cat_title(); ?></h2>
    	 	<?php /* If this is a tag archive */ } elseif( is_tag() ) { ?>
    		<h1 class="page-title"><?php single_tag_title(); ?></h1>
    		<?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    		<h1 class="page-title"><?php _e('Archive For ', 'undedicated'); ?><?php the_time('F jS, Y'); ?></h1>
    		<?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    		<h1 class="page-title"><?php _e('Archive For ', 'undedicated'); ?><?php the_time('F, Y'); ?></h1>
    		<?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    		<h1 class="page-title"><?php _e('Archive For ', 'undedicated'); ?><?php the_time('Y'); ?></h1>
    		<?php /* If this is an author archive */ } elseif (is_author()) { ?>
    		<h1 class="page-title"><?php _e('Author Archive', 'undedicated'); ?></h1>
    		<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
    		<h1 class="page-title"><?php _e('Blog Archives', 'undedicated'); ?></h1>
    	 	<?php } ?>
    
    		<?php while (have_posts()) : the_post(); ?>
    
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<div class="post-header">
    <h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
    </div>
    <div style="width: 170px; float: left; padding: 0 0 4px 10px">
    <?php if(empty($post->post_excerpt)) : ?>
    <?php echo '<a href="', get_permalink(), '">';
    if (has_post_thumbnail()) {
    	echo get_the_post_thumbnail( $post_id, 'thumbnail');
    }
    else {
    	echo
    		'<img src="', get_bloginfo('template_directory'), '/images/default.jpg','" width="150" height="150" alt="View Details" />';
    }
    echo '</a>';
    ?>
    </div>
    <div style="width: 528px; float: left; padding: 0 10px 4px 0">
    <div>
    <p class="metadata">
    <b>Price:</b> <?php echo get_post_meta($post->ID, 'Price', true); ?><br />
    <b>Project Type:</b> <?php echo get_post_meta($post->ID, 'Project Type', true); ?>
    </p>
    </div>
    <div style="border-top: 1px dotted #ccc; margin-top: 4px;">
    <?php the_excerpt(); ?>
    
    			<p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute( ); ?>" rel="bookmark"><img src="https://www.daddydealer.com/wp-content/themes/undedicated/images/details-btn.png" alt="View Complete Details"></a>
    <a href="#mydiv" rel="facebox" style="margin-left: 60px;"><img src="https://www.daddydealer.com/wp-content/themes/undedicated/images/inquiry.png"></a></p>
    <div id="mydiv" style="display: none">
    <form style="padding-left: 10px;" action="https://www.daddydealer.com/popform.php" method="POST" name="mypopForm">
    <h3 style="display: block;">Fields are required*</h3>
    <label><?php the_title(); ?></label><br />
    Name*
    <input id="NameFieldpop" style="background: #FAFAFA; padding: 3px; border: 1px solid #DDD; width: 200px; font-size: 14px; margin: 0px 0 18px 15px;" type="text" name="namepop" size="24" />
    <br />E-Mail*
    <input id="EmailFieldpop" style="background: #FAFAFA; padding: 3px; border: 1px solid #DDD; width: 200px; font-size: 14px; margin: 0px 0 18px 13px;" type="text" name="emailpop" size="19" />
    <br />Phone*
    <input id="PhoneFieldpop" style="background: #FAFAFA; padding: 3px; border: 1px solid #DDD; width: 200px; font-size: 14px; margin: 0px 0 18px 11px;" type="text" name="phonepop" size="19" />
    <br />Query/Message*
    <textarea id="Querypop" style="background: #FAFAFA; padding: 3px; border: 1px solid #DDD; width: 260px; margin: 0px 0 5px 0px;" name="querypop" rows="6" cols=""></textarea>
    <input style="width: 90px; height: 30px; font-size: 16px;" type="submit" name="submitpop" value="Submit" />
    </form>
    </div>
    
    			<?php else : ?>	
    
    				<?php wp_link_pages( __('before=<div class="post-page-links">Pages:&after=</div>', 'undedicated')) ; ?>
    
    			<?php endif; ?>
    </div>
    </div>
    <hr />
    
    		<div style="height: 15px"></div>
    		</div><!--#posts-->
    		<?php endwhile; ?>
    
    		<?php if (show_posts_nav()) : ?>
    		<div class="post-navigation">
    			<ul>
    				<li><?php next_posts_link( __('&laquo; Previous Page','undedicated')) ?></li>
    				<li><?php previous_posts_link( __('Next Page &raquo;','undedicated')) ?></li>
    			</ul>
    		</div>
    
    		<?php endif; ?>
    
    	<?php else : ?>
    
    		<h2 class="page-title"><?php _e('Not Found', 'undedicated'); ?></h2>
    		<p><?php _e('There are not posts belonging to this category or tag. Try searching below:', 'undedicated'); ?></p>
    		<?php get_search_form(); ?>
    
    	<?php endif; ?>

    Or please have a look at my archive page at https://www.daddydealer.com/property-in-faridabad/

    Please help me solve the issue,

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Same Post Title in Loop, not Getting Changed’ is closed to new replies.