View difference between Paste ID: ZdyQHUMx and Npq7K7gU
SHOW: | | - or go back to the newest paste.
1-
<!--?php 
1+
<?php 
2
 
3
//get subcat variables
4
add_action('genesis_before_loop','dswp_termtitle');
5
add_action('genesis_before_loop','dswp_listsubcats');
6
 
7
//display term title 
8
function dswp_termtitle() {
9-
    $title = '<h2 class="term-title"-->';
9+
    $title = '<h2 class="term-title">';
10
    $title .= single_term_title('', false );
11
    $title .= '';
12
    echo $title;
13
}
14
 
15
//list subcategories or siblings 
16
function dswp_listsubcats () {
17
    foreach (get_the_category('') as $category);
18
    $cat = get_query_var('cat'); 
19
    $cat_id=$category->cat_ID;
20
    $child_cats = get_categories('child_of='.$cat);
21
        if ($child_cats) { $args = array(
22
    'title_li' => '',
23
    'depth' => 1,
24
    'echo' => 1,
25
    'child_of' => $cat
26
    ); ?>
27
    <ul class="cats">
28-
    <?php wp_list_categories($args); ?-->
28+
    <?php wp_list_categories($args); ?>
29
    </ul>
30-
    <!--?php }
30+
    <?php }
31
} 
32
 
33
//loop additions
34
//REPLACE THE ONE WITH YOUR CATEGORY ID
35
     if (is_category_or_sub(25)) {
36
    remove_action('genesis_after_post_content', 'genesis_post_meta');
37
    remove_action('genesis_before_post_content', 'genesis_post_info');
38
    add_action('genesis_before_post_title', 'dswp_grid_loop_image');
39
    add_action('genesis_after_post', 'dswp_grid_divider');
40
    }
41
 
42
// Use the prepared grid loop & new image 
43
 
44
  //REPLACE THE 1 WITH YOUR CATEGORY ID
45
     if (is_category_or_sub(25)) {
46
    remove_action( 'genesis_loop', 'genesis_do_loop' );
47
    add_action( 'genesis_loop', 'dswp_grid_helper' );     
48
    }
49
 
50
       //grid loop image function
51
        function dswp_grid_loop_image() {
52
            if ( in_array( 'genesis-grid', get_post_class() ) ) {
53
                global $post;
54-
                    echo '<p class="thumbnail"--><a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'thumbnail').'</a><p></p>';
54+
                    echo '<p class="thumbnail"><a href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'thumbnail').'</a><p></p>';
55
            }
56
        }
57
 /**
58
 * Grid Loop Divider
59
 * @author Bill Erickson
60
 * @link http://www.billerickson.net/genesis-grid-loop-content/
61
 *
62
 */
63
function dswp_grid_divider() {
64
    global $loop_counter, $paged;
65
    if ((($loop_counter + 1) % 3 == 0) && !($paged == 0 && $loop_counter < 2) ) echo '<hr>';
66
}
67
 
68
        //grid function 
69
        function dswp_grid_helper() {
70
    
71
            // Ensure the arguments for the normal query for the page are carried forwards
72
            global $query_string, $paged;
73
  
74
            // If you're using a Page to query the posts (e.g. with the Blog template), comment out the next line.
75
            wp_parse_str( $query_string, $query_args );
76
  
77
            $grid_args = array(
78
                'features' => 0,
79
                'feature_image_size' => 0,
80
                'feature_image_class' => 'alignleft post-image',
81
                'feature_content_limit' => 0,
82
                'grid_image_size' => '0',
83
                'grid_image_class' => 'alignleft post-image',
84
                'grid_content_limit' => -1,
85
                'more' => __( '', 'genesis' ),
86
//change this if you would like more or less photos per page
87
                'posts_per_page' => 24,
88
            );
89
  
90
        // Make sure the first page has a balanced grid
91
            if ( 0 == $paged )
92
        // If first page, add number of features to grid posts, so balance is maintained
93
        $grid_args['posts_per_page'] += $grid_args['features'];
94
            else
95
        // Keep the offset maintained from our page 1 adjustment
96
        $grid_args['offset'] = ( $paged - 1 ) * $grid_args['posts_per_page'] + $grid_args['features'];
97
  
98
    // Merge the standard query for this page, and our preferred loop arguments
99
    genesis_grid_loop( array_merge( (array) $query_args, $grid_args ) );
100
    }
101
 
102
    genesis();