This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Multiple Custom Query Strings?

  • Creator
    Topic
  • #1330
    ironspider
    Member

    Hi, I am working in the “Builder” making a layout that I will have linked to a menu item that displays a post grid based on a subset of posts. Basically I want to filter the results of the post grid to a category AND a tag AND then sort on AND sort by 🙂

    The custom query string works fine when I only have one thing in it (e.g. category_name=game_info ). But I need to put 4 items in that custom query string. When I try to separate them with commas it doesn’t work. it just returns the category custom string.

    So my question is “What is the format I need to write the Custom Query string in to use multiple parameters?”

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #1339
    Jason Bobich
    Keymaster

    Hello,

    In WordPress, when formatting a query string you use an ampersand to separate the parameters like this:

    category_name=game_info&foo=bar&foo2=bar2&foo3=bar3

    http://codex.wordpress.org/Class_Reference/WP_Query

    But you’ll see that with this you’re still a little limited as you can do everything possible with a WordPress query. There are many items available to you in the WP_Query object that will only work if you structure your parameters as an array, which cannot be done from this option in your WP admin.

    See #2 here for a trick to take this further: http://support.themeblvd.com/forums/topic/tip-simulate-post-grid-for-specific-pages/#post-985

    #1347
    ironspider
    Member

    Thanks Jason this helps. I am NEARLY there using the second option but please tell me I’m missing something simple. Basically I need to filter the post grid so that I can return things with a certain tag, and then order on title and, finally, orderby ASC.

    I can get it to work with the order and order by but I don’t know how to get it to also cut out everything that ISN’T the tag I want. This is what I have pasted into functions.php right now–what am I doing wrong? I must be putting that tag=EM line in wrong?

    /*
    Custom query for post lists/post grids
    */
    function my_custom_posts_query( $query, $args ){
    if( $args[‘query’] == ‘EM_order’ ){
    $query = array(
    ‘tag=EM’,
    ‘orderby’ => ‘title’,
    ‘order’ => ‘ASC’,
    );
    }
    return $query;
    }
    add_filter( ‘themeblvd_posts_args’, ‘my_custom_posts_query’, 10, 2 );

    #1349
    ironspider
    Member

    Okay I’ve actually figured that part out. But now I’m getting an issue where it seems to be ignoring what I’ve specified for the number of rows and columns I put in. Is that something I have to specify with the above array?

    What I mean to say is that I should have 11 results on the tag “EM”. The page (even though I’ve specified 5 posts per row) is showing 2 rows of 4 and 1 row of 2. Then there is a “2” down for pagination but when I click that it just reloads the current page.

    I see there is a posts_per_page array item but will this know to do 5 columns?

    #1351
    ironspider
    Member

    EDIT: Whoops! Looks like I had it set to 4 columns per row! I swear I didn’t but it says that and when I change it to 5 it works!

    Awesome!

    • This reply was modified 7 years, 11 months ago by ironspider.
    #1353
    ironspider
    Member

    But the pagination is not working. When I set it to “posts_per_page” at 10, save, and then view the reloaded page is shows me 10 posts (2 rows of 5 which is perfect) and a “2” for a second page but when I click the 2 it changes the URL to have a “&paged=2” at teh end of it but it still just shows me the original 10 items.

    Any thoughts on this snag?

    #1361
    Jason Bobich
    Keymaster

    Is this paginated post element on a layout applied to your homepage? How have you setup your homepage? Can I see a link to what you’ve setup?

    From your docs:

    =======

    It’s also important to note that the Layout Builder can be used to create a homepage like you see in the different theme demos. There are two ways to accomplish this:

    Method 1: Create your custom layout, apply it to a static page, and then assign that page as your static frontpage under Settings > Reading > Frontpage Displays.

    Method 2: Under Settings > Reading > Frontpage Displays, select “your latest posts.” Create your custom layout. Then, go to Appearance > Theme Options > Content > Homepage, and select your new custom layout as the content for the homepage. If you’re using an element in your custom layout that uses post pagination, make sure you use this method.

    =======

    So, if you’re doing Method #1, pagination will not work. Could this be what you’re experiencing?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The forum ‘Alyeska Responsive WordPress Theme’ is closed to new topics and replies.