• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

posts sorted with custom fields – pagination and infinite scroll

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › posts sorted with custom fields – pagination and infinite scroll

This topic is: not a support question

Tagged: Custom fields, genesis sample, infinite scroll, pagination, sort

  • This topic has 2 replies, 1 voice, and was last updated 7 years, 3 months ago by cyanoorange.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • February 1, 2016 at 7:21 am #178044
    cyanoorange
    Participant

    Hi everyone,
    I want to sort my posts with a custom field "kosmo_sortier_nr", because I want the user to sort the posts ASC and DSCN (and want to have better control than via the date function).
    So far so good.
    I have added a variable "aktion" to the hyperlink. If somebody clicks it aktion becomes 1 for the ASC and a two for DSCN link.
    With the code below the sorting works, but I have problems with the pagination. The last page link shows a "page not found". AND: I would like to make all this happen with an infinite scroll. I tried the "YITH Infinite Scrolling"-Plugin. But, if I have this on, I infnitily scroll through the first 5 posts. Could anyone help me with that? That would be really great. What am I doing wrong?
    Thnx
    ----
    My code in function.php:

    add_action('genesis_before_loop','sortierung_Kosmo');
    function sortierung_Kosmo(){
           $aktion = filter_input(INPUT_GET, 'aktion', FILTER_SANITIZE_STRING);
     if($aktion!=2 && is_home()){
    //     query_posts('meta_key=kosmo_sortier_nr&meta_compare=<=&meta_value=20&orderby=meta_value&order=ASC');
        $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
    
         query_posts('paged=' . $paged . '&posts_per_page=5&meta_key=kosmo_sortier_nr&meta_compare=<=&meta_value=20000000&orderby=meta_value&order=ASC'); 
    }
    }

    and

    add_action('genesis_before_loop','eintraege_umsortierenNeu');
    //add_action('init','eintraege_umsortierenNeu');
    function eintraege_umsortierenNeu(){
            $aktion = filter_input(INPUT_GET, 'aktion', FILTER_SANITIZE_STRING);
       if($aktion==2){
           $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
    
         query_posts('paged=' . $paged . '&posts_per_page=5&meta_key=kosmo_sortier_nr&meta_compare=<=&meta_value=20000000&orderby=meta_value&order=DSCN'); 
        }
    }
    February 1, 2016 at 9:33 am #178060
    cyanoorange
    Participant

    PS: This site works with the genesis-sample theme and wp- Version 4.4.1

    February 13, 2016 at 2:02 pm #178983
    cyanoorange
    Participant

    I opened a more structured threat to solve the problem and it looks like, that I have found the answer ...
    http://www.studiopress.community/topic/posts-sorted-with-custom-fields-pagination-problem/


    @admin
    : you can delete this threat, if its to confusing this was. thanx.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble