About Minimatica theme

Minimatic is a free well designed WordPress theme offering nice features for pictures rich website.

After support exchanges with webmasters wishing to do a multilingual website with xili-language plugin, some issues were discovered.

This example is provided as is for users and why not for author. The method of child theme was not used to be simplify the modifications and explanations.

The first issue concerns the second query in file loop-slider

7
8
9
10
11
12
13
14
15
16
17
18
19
20
  * @since Minimatica 1.0
 */
?>
<?php
	global $wp_query, $query_string;
	$paged = get_query_var( 'paged' );
	$args = array(
		'posts_per_page' => 4,
		'paged' => $paged,
		'ignore_sticky_posts' => 1
	);
	$args = wp_parse_args( $args, $wp_query->query );
?>
<?php query_posts( $args ); ?>

and the second, a filter added in functions.php to limit number of displayed images to 4.

123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 
/**
 * Overrides the default posts_per_page value when viewing in gallery mode
 * This prevents the 404 flag from being triggered when using query_posts() with pagination
 * It does not alter the database value for the option, only fiters it when the posts query is called
 *
 * @since Minimatica 1.0
 */
function minimatica_paged_posts( $query ) {
	if( (
		( $query->is_home() && 'gallery' == minimatica_get_option( 'homepage_view' ) ) ||
		( $query->is_category() && 'gallery' == minimatica_get_option( 'category_view' ) ) ||
		( $query->is_tag() && 'gallery' == minimatica_get_option( 'tag_view' ) ) ||
		( $query->is_author() && 'gallery' == minimatica_get_option( 'author_view' ) ) ||
		( $query->is_archive() && 'gallery' == minimatica_get_option( 'archive_view' ) )
		) && ( ! is_single() )
	)
		$query->set( 'posts_per_page', '4' );
}
endif;
 
add_filter( 'pre_get_posts', 'minimatica_paged_posts' );

The solution (tested on WP >=3.3) is based on a unique filter ‘post_limits’ for function ‘xili_minimatica_slider_limits ‘ (written on top of functions.php). The advantage is that only the original query remains.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/**
 * Filter to replace filter pre_get_posts + minimatica_paged_posts and
 * query_posts in loop-slider.php called if minimatica_get_option is true (see home.php) to keep only ONE query
 *
 * © dev.xiligroup.com - 2012-06-20
 */
function xili_minimatica_slider_limits ( $limits, $query_object = null ) {
	if ( 
		( $query_object->is_home && 'gallery' == minimatica_get_option( 'homepage_view' ) ) ||
		( $query_object->is_category && 'gallery' == minimatica_get_option( 'category_view' ) ) ||
		( $query_object->is_tag && 'gallery' == minimatica_get_option( 'tag_view' ) ) ||
		( $query_object->is_author && 'gallery' == minimatica_get_option( 'author_view' ) ) ||
		( $query_object->is_archive && 'gallery' == minimatica_get_option( 'archive_view' ) )
 
	) {
		// new values - see includes/theme-options.php
		$query_object->query_vars['ignore_sticky_posts'] = ( 'true' == minimatica_get_option( 'ignore_sticky_posts' ) );
		$query_object->query_vars['posts_per_page'] = minimatica_get_option( 'posts_per_page' ) ;
		// like in query.php
		$page = absint($query_object->query_vars['paged']);
			if ( empty($page) )
				$page = 1;
 
			if ( empty($query_object->query_vars['offset']) ) {
				$pgstrt = '';
				$pgstrt = ($page - 1) * $query_object->query_vars['posts_per_page'] . ', ';
				$limits = 'LIMIT ' . $pgstrt . $query_object->query_vars['posts_per_page'];
			} else { // we're ignoring $page and using 'offset'
				$q['offset'] = absint($query_object->query_vars['offset']);
				$pgstrt = $query_object->query_vars['offset'] . ', ';
				$limits = 'LIMIT ' . $pgstrt . $query_object->query_vars['posts_per_page'];
			}
 
	}
	return $limits;
}
add_filter ( 'post_limits', 'xili_minimatica_slider_limits', 10, 2 );

The unwished lines are commented or deleted…

To improve the settings, two values are added to the theme options window of appareance menu :
- the ‘quantity of posts’ displayed as image when slider/gallery mode is choosen.
- the ‘ignore sticky’ to decide if sticky post are displayed.
See file includes/theme-options.php (add_settings_field added and more)…


With these modifications, a multilingual website can be built with xili-language and the sub-selection of posts according language works well. Note: for current website, the performance is better because only one query is fired.

The package is renamed minimatic-xili and version is 1.0.8x. and usable as is !

Downloadable here minimatica-xili

Please comment on forum.

This entry was posted in Experts corner, xili-language. Bookmark the permalink.