サポート » テーマ » SightでGridをデフォルトにするとマウスオーバーが効かない

  • Sightというテーマを使っています。
    http://wpshower.com/themes/sight/

    トップページの表示方法がグリッドと記事一覧と切り替えができるのですが
    もともとは記事一覧がデフォルトになっています。

    グリッドをデフォルト表示にするために、
    http://wpshower.com/forums/archive/index.php/t-44.html?s=352eb89e91eb71e272a8baf86769ad7f

    を参考にloop.phpの3行目を下記に換えると、
    <div id=”loop” class=”<?php if ($_COOKIE[‘mode’] == ‘grid’) echo ‘grid’; else echo ‘grid’; ?> clear”>
    デフォルトでグリッド表示になるのですが、

    グリッド表示でサムネイルをマウスオーバーすると
    画像が切り替わって記事のタイトル等が表示されるものが、効かなくなってしまいます。

    上記のスレッドでも解決方法として、書き換えた内容をさらに<div id=”loop” class=”grid”>に書き換えればよい、と載っていましたが、変えても効きません。

    しかし以下のサイトでは、切り替え方は違いますが、マウスオーバーでタイトル表示ができるようになっています。
    http://macgamescout.org/
    http://blog.adesa.com/

    どこを触ればいいんでしょうか?
    素人なためさっぱり分かりません…。
    もしお分かりになる方がいらっしゃれば、レスいただけると助かります。

    loop.php

    <?php if ( have_posts() ) : ?>
    
        <div id="loop" class="<?php if ($_COOKIE['mode'] == 'list') echo 'list'; else echo 'grid'; ?> clear">
        <?php while ( have_posts() ) : the_post(); ?>
    
            <div <?php post_class('post clear'); ?> id="post_<?php the_ID(); ?>">
                <?php if ( has_post_thumbnail() ) :?>
                <a href="<?php the_permalink() ?>" class="thumb"><?php the_post_thumbnail('thumbnail', array(
                            'alt'	=> trim(strip_tags( $post->post_title )),
                            'title'	=> trim(strip_tags( $post->post_title )),
                        )); ?></a>
                <?php endif; ?>
    
                <div class="post-category"><?php the_category(' / '); ?></div>
                <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    
                <div class="post-meta">by <span class="post-author"><a
                        href="<?php echo get_author_posts_url(get_the_author_meta('ID')); ?>" title="Posts by <?php the_author(); ?>"><?php the_author(); ?></a></span>
                                       on <span
                            class="post-date"><?php the_time(__('M j, Y')) ?></span> <em>&bull; </em><?php comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments'), '', __('Comments Closed')); ?> <?php edit_post_link( __( 'Edit entry'), '<em>&bull; </em>'); ?>
                </div>
                <div class="post-content"><?php if (function_exists('smart_excerpt')) smart_excerpt(get_the_excerpt(), 55); ?></div>
            </div>
    
        <?php endwhile; ?>
    
        </div>
    
    <?php endif; ?>

    script.js

    jQuery.noConflict();
    (function($) {
        $(function() {
            /*** Dropdown menu ***/
    
            var timeout    = 200;
            var closetimer = 0;
            var ddmenuitem = 0;
    
            function dd_open() {
                dd_canceltimer();
                dd_close();
                var liwidth = $(this).width();
                ddmenuitem = $(this).find('ul').css({'visibility': 'visible', 'width': liwidth});
                ddmenuitem.prev().addClass('dd_hover').parent().addClass('dd_hover');
            }
    
            function dd_close() {
                if(ddmenuitem) ddmenuitem.css('visibility', 'hidden').prev().removeClass('dd_hover').parent().removeClass('dd_hover');
            }
    
            function dd_timer() {closetimer = window.setTimeout(dd_close, timeout);
            }
    
            function dd_canceltimer() {
                if (closetimer) {
                    window.clearTimeout(closetimer);
                    closetimer = null;
                }
            }
            document.onclick = dd_close;
    
            $('#dd > li').bind('mouseover', dd_open);
            $('#dd > li').bind('mouseout',  dd_timer);
    
            $('#larr, #rarr').hide();
            $('.slideshow').hover(
                function(){
                    $('#larr, #rarr').show();
                }, function(){
                    $('#larr, #rarr').hide();
                }
            );
    
            /*** View mode ***/
    
            if ( $.cookie('mode') == 'grid' ) {
                grid_update();
            } else if ( $.cookie('mode') == 'list' ) {
                list_update();
            }
    
            $('#mode').toggle(
                function(){
                    if ( $.cookie('mode') == 'grid' ) {
                        $.cookie('mode','list');
                        list();
                    } else {
                        $.cookie('mode','grid');
                        grid();
                    }
                },
                function(){
                    if ( $.cookie('mode') == 'list') {
                        $.cookie('mode','grid');
                        grid();
                    } else {
                        $.cookie('mode','list');
                        list();
                    }
                }
            );
    
            function grid(){
                $('#mode').addClass('flip');
                $('#loop')
                    .fadeOut('fast', function(){
                        grid_update();
                        $(this).fadeIn('fast');
                    })
                ;
            }
    
            function list(){
                $('#mode').removeClass('flip');
                $('#loop')
                    .fadeOut('fast', function(){
                        list_update();
                        $(this).fadeIn('fast');
                    })
                ;
            }
    
            function grid_update(){
                $('#loop').addClass('grid').removeClass('list');
                $('#loop').find('.thumb img').attr({'width': '190', 'height': '190'});
                $('#loop').find('.post')
                    .mouseenter(function(){
                        $(this)
                            .css('background-color','#FFEA97')
                            .find('.thumb').hide()
                            .css('z-index','-1');
                    })
                    .mouseleave(function(){
                        $(this)
                            .css('background-color','#f5f5f5')
                            .find('.thumb').show()
                            .css('z-index','1');
                    });
                $('#loop').find('.post').click(function(){
                    location.href=$(this).find('h2 a').attr('href');
                });
                $.cookie('mode','grid');
            }
    
            function list_update(){
                $('#loop').addClass('list').removeClass('grid');
                $('#loop').find('.post').removeAttr('style').unbind('mouseenter').unbind('mouseleave');
                $('#loop').find('.thumb img').attr({'width': '290', 'height': '290'});
                $.cookie('mode', 'list');
            }
    
            /*** Ajax-fetching posts ***/
    
            $('#pagination a').live('click', function(e){
                e.preventDefault();
                $(this).addClass('loading').text('LOADING...');
                $.ajax({
                    type: "GET",
                    url: $(this).attr('href') + '#loop',
                    dataType: "html",
                    success: function(out){
                        result = $(out).find('#loop .post');
                        nextlink = $(out).find('#pagination a').attr('href');
                        $('#loop').append(result.fadeIn(300));
                        $('#pagination a').removeClass('loading').text('LOAD MORE');
                        if (nextlink != undefined) {
                            $('#pagination a').attr('href', nextlink);
                        } else {
                            $('#pagination').remove();
                        }
                        if ( $.cookie('mode') == 'grid' ) {
                            grid_update();
                        } else {
                            list_update();
                        }
                    }
                });
            });
    
            /*** Misc ***/
    
            $('#comment, #author, #email, #url')
            .focusin(function(){
                $(this).parent().css('border-color','#888');
            })
            .focusout(function(){
                $(this).parent().removeAttr('style');
            });
            $('.rpthumb:last, .comment:last').css('border-bottom','none');
    
        })
    })(jQuery)
3件の返信を表示中 - 1 - 3件目 (全3件中)
  • 以下の記事のとおり
    <div id=”loop” class=”<?php if ($_COOKIE[‘mode’] == ‘grid’) echo ‘grid’; else echo ‘list’; ?> clear”>
    を <div id=”loop” class=”grid”> に書き方だけで
    grid表示で hover するようになりましたが
    http://bit.ly/vmHzOC

    修正です hoverは最初のアクセス時はきいていませんでした。 一度 Grid/Listをクリックすると表示されるますが・・すっきりしないです

    トピック投稿者 ykc

    (@ykc)

    teburaさま
    返信ありがとうございます。
    やはりそうですよね。。。
    上記のサイトでどこをどう触っているのかわかりません。
    これはあきらめるしかないかな~。

3件の返信を表示中 - 1 - 3件目 (全3件中)
  • トピック「SightでGridをデフォルトにするとマウスオーバーが効かない」には新たに返信することはできません。