Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #887059

    germanpulse
    Participant

    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)

    #887545

    Rad
    Moderator

    Hi 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.

    #891061

    germanpulse
    Participant

    Not 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

    #891695

    Jack
    Keymaster

    Hi 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!

    #891868

    germanpulse
    Participant

    The 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.

    #892728

    germanpulse
    Participant

    I 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.

    #892795

    Rue Nel
    Moderator

    Hey 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.

    #894636

    germanpulse
    Participant

    Well, 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

    #894639

    germanpulse
    Participant

    Upload 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 &rarr;', '__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;
    
    
    #895870

    Rad
    Moderator

    Hi 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!

    #895900

    germanpulse
    Participant

    I 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.

    #897137

    Rad
    Moderator

    Hi 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!

    #913660

    germanpulse
    Participant
    This reply has been marked as private.
    #914271

    Rad
    Moderator

    Hi 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!