将prettyPhoto集成到Wordpress主题中


Integrating prettyPhoto into Wordpress theme

我正在尝试将prettyPhoto集成到Wordpress主题中(我使用的是Sydney主题)。我做了以下工作:

  1. 将prettyPhoto.css文件上传到/css目录
  2. 将jquery-1.3.2.min.js和jquery.prettyPhoto.js文件上传到/js目录
  3. 已将所有图像文件夹(全屏、prettyPhoto、缩略图)上载到/images目录

然后,我添加了

<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>

到header.php文件,就在打开标记之后,如下所示:

?php
/**
 * The header for our theme.
 *
 * Displays all of the <head> section and everything up till <div id="content">
 *
 * @package Sydney
 */
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" />
<script src="js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
<?php if ( ! function_exists( 'has_site_icon' ) || ! has_site_icon() ) : ?>
	<?php if ( get_theme_mod('site_favicon') ) : ?>
		<link rel="shortcut icon" href="<?php echo esc_url(get_theme_mod('site_favicon')); ?>" />
	<?php endif; ?>
<?php endif; ?>
<?php wp_head(); ?>
<!--
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $('#button').click(function(e) {  
        var inputvalue3 = $("#input").val();
        
    });
});
</script> 
-->
</head>

然后,为了初始化prettyPhoto,我添加了

<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>

到footer.php文件中,就在结束标记之前,如下所示:

<?php
/**
 * The template for displaying the footer.
 *
 * Contains the closing of the #content div and all content after
 *
 * @package Sydney
 */
?>
			</div>
		</div>
	</div><!-- #content -->
	<?php if ( is_active_sidebar( 'footer-1' ) ) : ?>
		<?php get_sidebar('footer'); ?>
	<?php endif; ?>
    <a class="go-top"><i class="fa fa-angle-up"></i></a>
	<footer id="colophon" class="site-footer" role="contentinfo">
		<div class="site-info container">
			<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'sydney' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'sydney' ), 'WordPress' ); ?></a>
			<span class="sep"> | </span>
			<?php printf( __( 'Theme: %2$s by %1$s.', 'sydney' ), 'aThemes', '<a href="http://athemes.com/theme/sydney" rel="designer">Sydney</a>' ); ?>
		</div><!-- .site-info -->
	</footer><!-- #colophon -->
</div><!-- #page -->
<?php wp_footer(); ?>
<script type="text/javascript" charset="utf-8">
  $(document).ready(function(){
    $("a[rel^='prettyPhoto']").prettyPhoto();
  });
</script>
</body>

现在,在我的wordpress页面上,有一个部分,由一个名为"fp-call-to-action.php"的文件描述

此文件包含一个按钮。点击按钮后,我想要一个youtube视频在灯箱中打开,使用prettyPhoto:

<div>
                        <a href="http://www.youtube.com/watch?v=40wYKjSd9r0" rel="prettyPhoto" title="youtube">
                        <button type="button" id="button">Jetzt anschauen!</button>
                        </a>
                        </div>

然而,每次我点击按钮,我都会被重定向到youtube。这个视频就是无法在灯箱中打开。

我哪里搞错了?

非常感谢你的帮助!!

我终于解决了这个问题。链接是错误的,完全是新手的错误。我很抱歉!