gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 05:40:11 48 4
gpt4 key购买 nike

我是 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/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com