php - WordPress 鼠标悬停在带有背景颜色的文本上?

标签 php jquery css wordpress

我是 WordPress 新手,使用的是 4.2.2 版本。我需要将鼠标悬停在背景颜色上并在图像上显示文本。给定的文本和图像是从管理面板动态生成的。我提供了以下图片供您引用,第一张图片现在我有我的网站,下一张图片我需要这样做。

enter image description here

enter image description here

提前致谢!

最佳答案

您可以将此功能用于wordpress

<?php wp_get_attachment_image( $attachment_id, $size, $icon, $attr ); ?>

<?php wp_get_attachment_metadata( $attachment_id, $unfiltered ); ?>

这是法典

https://codex.wordpress.org/Function_Reference/wp_get_attachment_image https://codex.wordpress.org/Function_Reference/wp_get_attachment_metadata

有了这个,你可以获得图像的名称并像 Sagar 所说的那样显示

您将在您的页面中使用它,而不是在您的functions.php中

你不会在函数中使用 this,你会在你的页面中使用 this,就像这样

<?php 
     $my_query = new WP_Query('post_type=eventos&category_name=galeria_evento&posts_per_page=1');
                    while ($my_query->have_posts()) : $my_query->the_post(); 
                        ?>

                    <?php
                        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                        $args = array(
                                        'post_type' => 'attachment',
                                        'post_parent' => $post->ID,
                                        'numberposts' => -1,
                                        'paged' => get_query_var('paged'),
                                        'exclude' => get_post_thumbnail_id()
                                    );

                   // making the list of the attachments
                        $attachments = get_posts( $args );
                        if ( $attachments ) {
                            foreach ( $attachments as $attachment ) {
                            // getting the image and title of the attachment
                            echo "<div class='item-slide'><p class='title-slide'>".apply_filters( 'the_title', $attachment->post_title )."</p>".wp_get_attachment_image( $attachment->ID, 'full' )."</div>";                                
                            }
                        }
                    ?>


            <?php endwhile; ?>

关于php - WordPress 鼠标悬停在带有背景颜色的文本上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31239319/

相关文章:

javascript - 禁用 javascript 时重定向单页网站

PHP MYSQL 插入类树

javascript - 如何在浏览器的滚动条中只隐藏拖动元素?

c# - Razor 语法 PHP 等价物

php - 向 crontab 传递一个变量并从 PHP 读取它?

javascript - 如何使用javascript防止ajax响应中的window.onbeforeunload函数

javascript - 如何复制文件输入值?

php - 如何在 jquery ui 自动完成中使用 json 传递隐藏的 id?

html - 如何使 img-list 在桌面上保持在一行但在移动设备上下拉

javascript - 单击时缩小的按钮的可单击区域