Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php wordpress主题的默认网格布局_Php_Wordpress - Fatal编程技术网

Php wordpress主题的默认网格布局

Php wordpress主题的默认网格布局,php,wordpress,Php,Wordpress,我在wordpress主题视图的多布局选项上遇到问题 点击按钮,流量可以选择网格或列表布局。目前,列表布局是默认的。我对使网格布局成为默认布局感兴趣 这是php的一部分,我尝试简单地将单词grid替换为list,但尽管这在一定程度上起作用,但如果在loop.php页面上执行,它将删除网格格式的邮箱上的a:hover函数。如果在index.php上完成,它还会切换主索引页面上的按钮 有什么想法吗 loop.php <div id="loop" class="<?php if ($

我在wordpress主题视图的多布局选项上遇到问题

点击按钮,流量可以选择网格或列表布局。目前,列表布局是默认的。我对使网格布局成为默认布局感兴趣

这是php的一部分,我尝试简单地将单词grid替换为list,但尽管这在一定程度上起作用,但如果在loop.php页面上执行,它将删除网格格式的邮箱上的a:hover函数。如果在index.php上完成,它还会切换主索引页面上的按钮

有什么想法吗

loop.php

   <div id="loop" class="<?php if ($_COOKIE['mode'] == 'grid') echo 'grid'; else     echo 'list'; ?> 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>  -->  

<?php edit_post_link( __( 'Edit entry'), '<em>&bull; </em>'); ?>

 <div class="post-content"><?php if (function_exists('smart_excerpt')) smart_excerpt(get_the_excerpt(), 55); ?></div>
    </div>

  <?php endwhile; ?>

   </div>

        <?php endif; ?>


我知道这不是最新的问题。但我想会有更多的人在寻找答案。所以我来试试。
所以我想我们有很多问题:

  • 您禁用了hover函数,因为您在注释括号内放置了太多代码。我猜你只是想除掉作者?!这应该做到:

    <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> -->
    
    最后,您必须将mode.png旋转180°


    对我有用:在我的网站上查看:。

    所以很遗憾,我不能评论我以前的答案。是的,我知道这个话题很古老,但有一个解决办法。由于需要更改多个文件,可在此处找到完整答案:

    <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> -->
    
    <a href="javascript: void(0);" id="mode"<?php if ($_COOKIE['mode'] == 'list') echo ' class="flip"'; ?>></a>
    
    <div id="loop" class="<?php if ($_COOKIE['mode'] == 'list') echo 'list'; else echo 'grid'; ?> clear">
    
        <a href="javascript: void(0);" id="mode"<?php if ($_COOKIE['mode'] == 'list') echo ' class="flip"'; ?>></a>
    
            /*** View mode ***/
    
        if ( $.cookie('mode') == 'grid' ) {
            grid_update();
        } else if ( $.cookie('mode') == 'list' ) {
            list_update();
        }
    
        $('#mode').toggle(
            function(){
                if ( $.cookie('mode') == 'list' ) {
                    $.cookie('mode','grid');
                    grid();
                } else {
                    $.cookie('mode','list');
                    list();
                }
            },
            function(){
                if ( $.cookie('mode') == 'grid') {
                    $.cookie('mode','list');
                    list();
                } else {
                    $.cookie('mode','grid');
                    grid();
                }
            }
        );
    
        function grid(){
            $('#mode').removeClass('flip');
            $('#loop')
                .fadeOut('fast', function(){
                    grid_update();
                    $(this).fadeIn('fast');
                })
            ;
        }
    
        function list(){
            $('#mode').addClass('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','#DADADA')
                        .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');
        }