php - 仅在单击帖子时显示按钮

标签 php jquery html css wordpress

我正在创建一个 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>

对于第一个帖子,社交图标框仅在我单击该帖子时显示。 然而,在上一篇文章中,我还可以在主页“更多”按钮下方看到社交媒体图标。

有谁知道这是为什么以及我该如何解决?

最佳答案

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

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

    });

关于php - 仅在单击帖子时显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29760429/

相关文章:

html - 如何使用 flexbox 对列表项进行排序?

jquery - 什么是用于 HTML Web 表单换肤的优秀 jQuery 插件(或纯 JavaScript 库)?

php - 使用 LOAD DATA LOCAL INFILE 从 CSV 添加数据库行,并为每一行添加一个唯一的字段

javascript - 将鼠标悬停在文本上时显示图像

php - 使用 PHP 注销非事件用户

jquery - 如何使用 colorbox 显示 iframe

javascript - 在 JavaScript 中为移动浏览器附加链接

javascript - 具有延迟调整的 onclick 切换类

php - 使用 preg_match_all() 或更好的函数获取标签之间的所有文本?

php - 为什么libcurl会计算 "4 TIMES"添加easy handles的个数?