ブログ記事が無い場合のバグ
-
またまたお世話になります。
smoothgalleryの時は大変お世話になり本当にありがとうございました。前回、前々回とこちらでお世話になったページがようやく完成間近となったのですが、今度はループが間違っているのか、変なところでバグが起きてしまいます。
記事があるときは記事を表示して、記事が無い場合は「記事がありません」と表示するようにしたくてループを作ったのですが、見た目はその通りになり大変良いのに「記事がありません」を表示したときのみ全然関係ない場所ので囲ったリンクが消えてしまうようになってしまいました。
下記がコードです。
※申し訳ありませんが非常に稚拙な知識で作成してますのでhtmlもphpもあまりきれいな作りにはなっていませんので見にくいかとおもいます。header.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja" dir="ltr"> <head> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>;charset=<?php bloginfo('carset'); ?>" /> <meta http-equiv="Content-Langage" content="ja" /> <title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> &requo; Blog Archive <?php } ?> <?php wp_title(); ?></title> <meta name="description" content="<$MTEntryExcerpt$>" /> <meta name="keywords" content="歴史座会,歴史を学び生き方を考える座会," /> <meta name="copyright" content="Copyright(C)nomoto-osamu.com" /> <link rev="made" href="mailto:info@r-ine.org" /> <link rel="section" href="index.html" /> <link rel="stylesheet" href="<?php bloginfo( 'stylesheet_url' ); ?>" /> <link rel="shortcut icon" href="<?php bloginfo('template_url'); ?>/images/favicon.ico" /> </head> <body> <div id="container"> <div id="header"> <div id="logo"> <a href="http://www.nomoto-osamu.com/rekishi/index.html"><img src="<?php bloginfo('template_url'); ?>/images/logo.jpg" alt="<?php bloginfo('name'); ?>" width="210" height="58" /></a> </div><!-- /.logo --> <p id="presents">埜<span class="moto">本</span>修 presents</p> <p class="line"></p> </div><!-- /.header -->
index.php
<?php get_header(); ?> <div id="contents"> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div id="left-side"> <p class="year"><?php the_date('Y') ?></p> <p class="date"><?php the_time('md') ?></p> <p class="time"><?php the_time(); ?></p> <p class="title"><?php the_title(); ?></p> <div id="article" class="flexcroll"> <p class="scroll"><?php the_content(); ?></p> </div><!-- /.article --> </div><!-- /.left-side --> <div id="right-side"> <div id="myGallery"> <?php $images = get_children(array('post_parent' => get_the_ID(),'post_type' =>'attachment')); foreach ( $images as $attachment_id => $attachment ) { //var_dump($attachment); ?> <div class="imageElement"> <h3><?php echo $attachment->post_title; ?></h3> <p><?php echo $attachment->post_content; ?></p> <a href="<?php echo wp_get_attachment_url( $attachment_id ); ?>" title="open image" class="open"></a> <img src="<?php echo wp_get_attachment_url( $attachment_id ); ?>" class="full" alt=""/> </div><!-- /.imageElement --> <?php } ?> </div> <!-- /.myGallery --> <div id="page-navi"> <?php wp_pagenavi(); ?> </div><!-- /.page-navi --> <?php endwhile; ?> </div><!-- /.right-side --> <?php else : ?> <h2 class="text-center">記事がありません。</h2> <?php endif; ?> </div><!-- /.contents --> <?php get_footer(); ?>
footer.php
<div id="footer"> <ul> <li><a href="http://www.nomoto-osamu.com/rekishi/index.html">トップ</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/whats.html">歴史座会とは</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/profile.html">プロフィール</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/contents.html">歴史座会</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/blog.html">Blog</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/link.html">リンク</a></li> <li><a href="http://www.nomoto-osamu.com/rekishi/sitemap.html">サイトマップ</a></li> </ul> <address>Copyright © <?php echo date('Y'); ?> nomoto-osamu.com All Rights Reserved.</address> </div><!-- /.footer --> </div><!-- /.container --> <script type="text/javascript" src="http://nomoto-osamu.com/rekishi/blog/wp-content/themes/rekishizakai/script/flexcroll.js"></script> <link rel="stylesheet" type="text/css" href="http://nomoto-osamu.com/rekishi/blog/wp-content/plugins/smoothgallery/smoothgallery.php?smoothgallery_action=css&prefix=http%3A%2F%2Flocalhost%2Fwordpress%2Fwp-content%2Fplugins%2Fsmoothgallery&ct=1&height=345&width=460&bordercolor=000" /> <script src="http://nomoto-osamu.com/rekishi/blog/wp-content/plugins/smoothgallery/scripts/mootools.js" type="text/javascript"></script> <script src="http://nomoto-osamu.com/rekishi/blog/wp-content/plugins/smoothgallery/scripts/jd.gallery.js" type="text/javascript"></script> <script src="http://nomoto-osamu.com/rekishi/blog/wp-content/plugins/smoothgallery/scripts/jd.gallery.transitions.js" type="text/javascript"></script> <script type="text/javascript"> function startGallery() { var myGallery = new gallery($('myGallery'), { showCarousel: false }) } window.addEvent('domready', startGallery); </script> </body> </html>
この3つで構成されてます。
「記事がありません」となった際にフッターのリストになっている部分のリンクが外されてしまいます。(文字は表示しています。)
記事があった場合はちゃんとリンクもありますので何が何やら全然わからない状態です。
因みにheaderの<div id=”logo”>の画像につけたリンクは生きています。何かわかる事がありましたらご指摘お願い致します。
1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
- トピック「ブログ記事が無い場合のバグ」には新たに返信することはできません。