wp:axaj特色图像随更改而变化,从选项中选择帖子标题

时间:2018-09-13 19:32:36

标签: ajax

我有帖子类型[服务]循环所有帖子类型选项 并在选择选项时显示其特色图片

enter code here
<form method="post" action="">
        <div class="form-group-field">
            <div class="left_label"><label>
                    Select Post
                </label></div>
            <div class="rigth_input">
                <select id="vzxms-post-slct" name="vzxms-post-slct" class="vzxms-post-slct">
                    <?php
                    $args = array( 'post_type'=>'services');
                    $myposts = get_posts( $args );
                    foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
                        <option value="<?php echo get_permalink();?>&json=1"><?php the_title(); ?></option>
                    <?php endforeach;
                    wp_reset_postdata();?>
                </select>
                <!-- and here i want to show image -->
                <?php
                // $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'post');
                // echo $thumb[0];
                ?>
                <!--<img src="<?php echo $thumb[0]; ?>" id="post-thumb"/>-->
                <h6 id="post-tit"></h6>
                <div id="post-cont"></div>
            </div>
        </div>
    </form>

enter image description here

0 个答案:

没有答案