Tagged: x
-
AuthorPosts
-
April 17, 2016 at 2:13 pm #887059
I am trying to find a way to offset the posts using the plugin The Grid and cannot find out how this is done. I’d like to have multiple grids laid out on a page with a break in between to place other content and then have the posts resume where they left off on the other.
The plugin developer stated that this is possible in a comment on the CodeCanyon page, but would not say how to accomplish it unless the plugin is purchased directly. Any help would be appreciated. (I cannot post a URL or login credentials as the site is being run on a local server while in development)
April 18, 2016 at 12:48 am #887545Hi there,
Thanks for posting in.
Their documentation is available here http://theme-one.com/docs/the-grid/
The usage of offset is similar to how you do it in WP_Query’s offset of WordPress, but this time, you’ll use it within The Grid’s code. Like from here
http://theme-one.com/docs/the-grid/#!/query_filter
The complete example is this, just by adding to child theme’s functions.php
function my_query_args($query_args, $grid_name) { if ($grid_name == 'My grid name') { // all query parameters can be modified (https://codex.wordpress.org/Class_Reference/WP_Query) $query_args['offset'] = 10; } return $query_args; } add_filter('tg_wp_query_args', 'my_query_args', 10, 2);
Hope this helps.
April 19, 2016 at 8:59 pm #891061Not sure what I am missing but this does not seem to be doing anything. I copied your example exactly, only replacing ‘My grid name’ with the actual name of my grid I want to apply the offset to. I am including the code I used below:
function my_query_args($query_args, $grid_name) { if ($grid_name == 'News') { // all query parameters can be modified (https://codex.wordpress.org/Class_Reference/WP_Query) $query_args['offset'] = 10; } return $query_args; } add_filter('tg_wp_query_args', 'my_query_args', 10, 2);
I placed this in the functions.php of my X-Theme child
April 20, 2016 at 7:40 am #891695Hi there,
Thanks for writing back!
That should be working, can you post your wp-admin and FTP details in a private reply please, so we can check this for you.
Thanks!
April 20, 2016 at 9:28 am #891868The site is in development and is being run locally. I do not have any caching on the development site, and even when I copied over code from the official documentation, that would not work either. This seems to be a common issue I am having with The Grid… can’t even make custom skins work.
April 20, 2016 at 7:59 pm #892728I seem to have figured out the solution. I moved the code to be the first thing in my functions.php and that made it work. Not sure why this is the fix, but it seems to have done the trick.
April 20, 2016 at 9:05 pm #892795Hey There,
We are just glad that you have figured it out a way to correct the said issue.
Thanks for letting us know!Best Regards.
April 21, 2016 at 9:27 pm #894636Well, that was short lived… started work on the site today and the offset was no longer working. This is very frustrating.
I am going to try to attach my function file, as I can not offer login credentials since this development site is run locally. Let me know if there are any additional files you want me to attach
April 21, 2016 at 9:29 pm #894639Upload didn’t work so hopefully this will do it
<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // ============================================================================= // Grid Offset // ============================================================================= function my_query_args($query_args, $grid_name) { if ($grid_name == 'Archives') { // all query parameters can be modified (https://codex.wordpress.org/Class_Reference/WP_Query) $query_args['offset'] = 12; } return $query_args; } add_filter('tg_wp_query_args', 'my_query_args', 10, 2); // Entry Meta // ============================================================================= if ( ! function_exists( 'x_integrity_entry_meta' ) ) : function x_integrity_entry_meta() { // // Author. // $author = sprintf( '<span><a href="%1s"> %2s</a></span>', get_author_posts_url(get_the_author_meta( 'ID' )), get_the_author() ); $authoremail = sprintf( '<span class="p-meta-social"><a href="mailto:%1$s"><i class="x-icon-envelope" data-x-icon=""></i> Email</a></span>', get_the_author_meta( 'user_email' ), get_the_author_meta( 'user_email' ) ); $authortwitter = sprintf( '<span class="p-meta-social"><a href="http://twitter.com/%1$s"> <i class="x-icon-twitter" data-x-icon=""></i> %2$s </a></span>', get_the_author_meta( 'twitter' ), get_the_author_meta( 'twitter' ) ); // // Date. // $date = sprintf( '<time class="entry-date" datetime="%1$s"> %2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); // // Output. // if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">By %1$s on %2$s% / %3$s%4$s</p>', $author, $date, $authoremail, $authortwitter ); } } endif; // Excerpt More String // ============================================================================= if ( ! function_exists( 'x_excerpt_string' ) ) : function x_excerpt_string( $more ) { $stack = x_get_stack(); if ( $stack == 'integrity' ) { return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Read Story →', '__x__' ) . '</a></div>'; } else if ( $stack == 'renew' ) { return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Read Story', '__x__' ) . '</a>'; } else if ( $stack == 'icon' ) { return ' ...'; } else if ( $stack == 'ethos' ) { return ' ...'; } } add_filter( 'excerpt_more', 'x_excerpt_string' ); endif;
April 22, 2016 at 3:21 pm #895870Hi there,
It’s correct, but I can’t test it. Would you mind providing your admin and FTP login credentials in private reply? I like to check it too.
Thanks!
April 22, 2016 at 3:50 pm #895900I would if I could, but like I have said now 3 times, the site is being worked on locally while in development. I would be happy to past code from any other file if it would help.
April 23, 2016 at 11:56 pm #897137Hi there,
It appears to be working on my installation. The code is even provided at The Grid’s documentation. I think what’s left is checking it why it’s not working on your end. But as you said, it’s local and we can’t check it.
Please setup a live demo where we can test it.
Thank!
May 4, 2016 at 10:11 pm #913660This reply has been marked as private.May 5, 2016 at 9:05 am #914271Hi there,
Ah, your The Grid version is 1.4.0, that tg_wp_query_args filter is only available at 1.5.0. It will only work if you upgrade it, but unfortunately, there is no update available yet. Stay tuned.
Thanks!
-
AuthorPosts