Php WordPress鼠标悬停在背景色文本上?

Php WordPress鼠标悬停在背景色文本上?,php,jquery,css,wordpress,Php,Jquery,Css,Wordpress,我是wordpress新手,使用的是4.2.2版本。我需要显示鼠标在背景色与文字的图像。给定的文本和图像是从管理面板动态生成的。我已经给了你参考下面的图片,第一张图片现在我有我的网站,下一张图片我需要这样做 提前谢谢 您可以将此功能用于wordpress <?php wp_get_attachment_image( $attachment_id, $size, $icon, $attr ); ?> 或 这是抄本 有了这个,你可以得到图像的名称,并显示像萨加尔说 您将

我是wordpress新手,使用的是4.2.2版本。我需要显示鼠标在背景色与文字的图像。给定的文本和图像是从管理面板动态生成的。我已经给了你参考下面的图片,第一张图片现在我有我的网站,下一张图片我需要这样做


提前谢谢

您可以将此功能用于wordpress

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


这是抄本

有了这个,你可以得到图像的名称,并显示像萨加尔说

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

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

<?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; ?>


这里已经有一把小提琴了。谢谢sagar,我将检查这一点以及如何在WordPress中集成。我使用的是enfold主题,我不知道哪个文件用于显示输出。这是我的网站和我的页面,()我需要知道这个的文件路径。请告诉我。我在这方面苦苦挣扎了几天。最后我用css写东西,并用文本显示鼠标。谢谢你的支持。这些照片来自wordpress页面,那么我怎样才能包含这些功能呢。我想我需要编辑页面或模板文件来正确使用这些功能?然后我需要找到哪个css文件适用于这些页面,包括css代码,对吗?我对在哪个文件中编写代码感到困惑。不,你不需要对代码做太多更改,只需使用foreach来获取附件,并使用wp_get_attachment_meta($id)来获取foreach中关于附件的信息,我会找到我使用这一次的地方,并将代码放在这里,在哪个文件中我需要添加这个函数我已经找到了文件的位置,这里已经有了这个函数。这是post.php文件中的函数。函数wp_get_attachment_metadata($post_id=0,$unfiltered=false){$post_id=(int)$post_id;if(!$post=get_post($post_id))返回false;$data=get_post_metadata($post->id,''wp_attachment_metadata',true);if($unfiltered)返回$data;返回apply过滤器('wp_get_attachment_metadata',$post->id)}你正在获得标题,现在你只需在wordpress的“媒体”选项卡中的图像中添加一个标题
<?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; ?>