我有一个存档页面,它显示了一个自定义的帖子类型,其中包含在ACF中输入的内容。在每篇文章中,有两个按钮可以打开查询模式和库模式。现在,我已经成功地使用了查询按钮,该按钮将填充一个下拉列表,其中预选了帖子的标题(感谢我之前提出的一个问题的帮助:Set default option in dropdown of WP_Query?). 现在问题在于模态库。单击按钮时,不会弹出任何内容。我想打开与该帖子关联的acf图库的modal图库。
以下是带有按钮的文章代码:
<div class="property-info">
<?php $the_post = get_post(); ?>
<div class="property-details">
<h2><?php the_title(); ?></h2>
<h3 class="address"><?php echo get_field(\'property_address\');?></h3>
<!-- excerpt -->
<p><?php if( \'\' != get_the_excerpt(40) || \'\' != get_the_content(40) ) { ?>
<?php do_action(\'layers_before_list_post_content\'); ?>
<?php do_action(\'layers_list_post_content\'); ?>
<?php do_action(\'layers_after_list_post_content\'); ?>
<?php } ?></p>
</div>
<div style="width:48%;display:inline-block;padding-right:10px">
<!-- IF HAVE GALLERY, SHOW BUTTON FOR MODAL WINDOW-->
<a href="#open-modal-gallery-<?php echo $post->ID; ?>" class="button gallery-button">View Images</a>
<!-- END GALLERY MODAL WINDOW BUTTON -->
</div>
<div style="width:48%;display:inline-block;padding-left:10px;">
<!-- IF HAVE WEBSITE URL GO THERE, ELSE OPEN MODAL WINDOW, UNLESS DISABLED -->
<!-- <a href="<?php echo get_field(\'property_website\'); ?>" class="button inquire-button">Visit Website</a> -->
<a href="#open-modal-form-<?php echo $post->ID; ?>" class="button inquire-button">Inquiry</a>
<!-- END BUTTON -->
</div>
</div>
以下是查询模式的代码:
<!-- INQUIRY MODAL WINDOW -->
<div id="open-modal-form-<?php echo $post->ID; ?>" class="modal-window">
<div>
<a href="#" title="close" class="modal-close"><i class="eicon-close"></i></a>
<!-- I couldn\'t get contact form 7 to play nice, so I made my own form. Recipient Email is managed in inquiry.php. -->
<h2>Property Inquiry</h2>
<form action="<?php bloginfo(\'template_directory\'); ?>/inquiry.php" method="post">
<div class="col-6">
<input type="text" name="fname" placeholder="First name">
</div>
<div class="col-6">
<input type="text" name="lname" placeholder="Last name">
</div>
<div class="col-6">
<?php
$args = array(
\'post_type\' => \'property\',
\'tax_query\' => array(
array(
\'taxonomy\' =>\'project_category\',
\'field\' => \'slug\',
\'terms\' => array(\'current-projects\',\'past-projects\')
)
),
);
$post_id = $post->ID;
$the_query = new WP_Query($args);
?>
<select name="propname">
<?php
$found = wp_list_filter( $the_query->posts, [ \'ID\' => $the_post->ID ] );
if ( empty( $found ) ) :
?>
<option selected><?php echo get_the_title( $the_post ); ?></option>
<?php
endif;
if($the_query->have_posts()){
while($the_query->have_posts()) : $the_query->the_post(); ?>
<option<?php selected( get_the_ID(), $the_post->ID ); ?>><?php the_title(); ?></option>
<?php endwhile;
} wp_reset_query();
?>
</select>
</div>
<div class="col-6">
<input type="email" name="email" placeholder="Email">
</div>
<div class="col-12">
What type of lease are you looking for?
<input type="radio" name="lease-type" value="Rental Lease" id="rental-lease" checked> <label for="rental-lease">Rental</label>
<input type="radio" name="lease-type" value="Commercial Lease" id="commercial-lease"> <label for="commercial-lease">Commercial</label>
</div>
<div class="col-12">
<textarea name="comments" placeholder="Message"></textarea>
</div>
<div class="col-12" style="text-align:right;">
<input type="submit" value="Send Request">
</div>
</form>
<p><small>DB Services does not collect any personally identifiable information about you when you visit the Website unless you voluntarily provide this information, for example by contacting us through our email forms (including sending us queries or responding through the Website to our job postings.) Personal information collected in these cases may include your name, contact details, email address, telephone number and your resume.</small></p>
</div>
</div>
<!-- END INQUIRY MODAL WINDOW -->
代码正下方是画廊代码:
<!-- GALLERY MODAL WINDOW -->
<div id="open-modal-gallery-<?php echo $post->ID; ?>" class="modal-gallery">
<a href="#" title="close" class="modal-close"><i class="eicon-close"></i></a>
<div>
<?php
$images = get_field(\'gallery_\',$post->ID);
if($images):
?>
<div class="slick-gallery">
<?php foreach($images as $image) : ?>
<div class="img-container">
<img src="<?php echo $image[\'url\']; ?>" alt="<?php echo $image[\'alt\']; ?>" />
</div>
<?php endforeach; ?>
</div>
<div class="slider-nav">
<?php foreach( $images as $image ): ?>
<div>
<img src="<?php echo $image[\'url\']; ?>" alt="<?php echo $image[\'alt\']; ?>" />
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
</div>
<!-- END GALLERY MODAL WINDOW -->
我假设这是因为我在查询模式内重置了查询,但当我将$args语句移到查询模式外,并将其重置到gallery模式外时,什么都没有发生。调查结果仍然有效,但画廊模式根本没有打开。