【发布时间】:2013-04-12 03:58:55
【问题描述】:
我不是 PHP、javascript 和 js 方面的专家;所以我希望有人可以用简单的语言帮助我。我刚刚开发了我的第一个 wordpress 网站并极大地更改了代码,使用这个论坛 - 到目前为止非常感谢!
网站:http://www.heritageglass.com.au
我的要求:文本(媒体库中的图片描述)悬停在图片上。
就像这个website 或这个plugin,我在这个网站上发现了几个与我的问题有关的问题,但它们似乎没有帮助,或者我不知道该把它放在哪里,因为它正在抓取the_title 我想要the_description。有这样的名词吗?
portfolio.php 模板中的 PHP 代码:
<div data-id="post-<?php the_ID(); ?>" data-type="<?php
$categories = get_the_category();
$count = count($categories);
$i=1;
foreach($categories as $category) {
echo str_replace('-', '', $category->slug);
if ($i<$count) echo ' '; $i++;} ?>" class="post-<?php the_ID(); ?>
<?php
$categories = get_the_category();
foreach($categories as $category) {
echo str_replace('-', '', $category->slug).' '; } ?> project portfolio-item-wrap">
<div class="portfolio-item">
<?php if ( has_post_thumbnail() ) { ?>
<a class="portfolio-item-img" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'portfolio-image' ); ?></a>
<?php } ?>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p>
<?php
$categories = get_the_category();
$temp = array();
foreach($categories as $category) {
if ($category->category_parent == 0) continue;
$temp[] = str_replace('-', '', $category->name);
}
echo implode(", ", $temp);
?>
</p>
</div>
</div>
我发现了这个:Text over image using jquery and css 并在 header.php 中添加脚本。并使用了我的 .portfolio-item 和 .portfolio-item-img 而不是 .wrapper 和 .description - 但这并没有做任何事情。
希望有人能引导我走向正确的方向?
谢谢!
【问题讨论】:
-
你有很多嵌入在 HTML 标记中的单直接函数调用,例如
the_ID()、the_permalink()等。您确定这些函数是 echo out 某物而不是 return 某物吗? -
从您的描述中不确定您的问题到底是什么,但我知道 js 是 JavaScript 的缩写...
-
对不起,我的意思是 jquery。并且关于单直接函数调用,所有这些代码都与我购买的 wordpress 主题无关。询问作者被视为定制。
标签: php javascript jquery hover