首页 文章

仅在单击Wordpress时显示按钮

提问于
浏览
1

我正在创建一个wordpress主题 . 我有一个带有一些社交网络按钮的盒子 . 当您单击帖子时,带有按钮的此框应仅显示在文章下方 .

在我的index.php中,我有以下内容

<div class="left-column">
            <?php if (have_posts()) :
            while(have_posts()): the_post(); ?>

            <article class="post">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <p class="info author-info centered">by <a class="info" href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>"> <?php the_author(); ?></a> 
                <p><?php the_time('F d, Y'); ?></p>
                </p>
                <?php the_content('MORE'); ?>

            </article>

            <?php

                endwhile; 

                else:
                    echo '<p>No content found</p>';

                endif; 

            ?>
            <!-- Widget underneath post -->
            <div class="undereath-post">
                <?php dynamic_sidebar('underpost1');?>
                <!-- Social buttons -->
                <div class="social-button-box">
(Here would go the code for all the social media buttons)
</div>

对于第一篇文章,社交图标框仅在我点击帖子时显示 . 然而,在最后一篇文章中,我可以在“更多”按钮下方的主页面上看到社交媒体图标 .

有谁知道为什么会这样,以及如何解决它?

1 回答

  • 1

    使用一些jquery并做这样的事情

    $(".social-button-box").hide();    
    $(".post").click(function(){
        $(this).each(".social-button-box", function(){$(this).show();});
    
        });
    

相关问题