nemseck
Forum Replies Created
-
Forum: Plugins
In reply to: [WP SAML Auth] Switch from Apache to NGINX environmentThanks for your answer. In the meantime I’ve figured it out what was the problem. We’re using WP-Hide PRO in order to change all basic WP paths for security reasons and the issue was caused by a conflict between virtual host rules and WP-Hide rewrite rules.
In particular the lines related to wp-login.php rewriting rules had to be declared at the very bottom of the virtual host configuration. Probably the priority of rewriting rules generated a mismatch in the response.
Forum: Fixing WordPress
In reply to: Random post order and pagination for a specific queryAnd sorry for moderators, I think the better title for this post would be
“Making isotope+infinite scroll working with wordpress pagination without duplicate items on stream”Forum: Fixing WordPress
In reply to: Random post order and pagination for a specific queryWell, finally I’ve found a solution for my issue. So I fixed how to have an infinite scroll with random post order, preventing the possibility to have duplicate posts on my page.
Before I have to say I’m actually using both jQuery isotope combined with infinite-scroll. In fact my solution is jQuery-oriented.
First step: I just cleaned up the main loop and all the queries that feed it like this:
$args_type1 = array( // query for first post type 'fields' => 'ids', 'post_type'=> 'type_1', 'showposts' =>30, 'orderby'=>'date' ); $type1_ids = get_posts( $args_type1 ); $args_type2 = array( // query for second post type 'fields' => 'ids', 'post_type'=> 'type_2', 'showposts' =>30, 'orderby'=>'date' ); $type2_ids = get_posts( $args_type2 ); $args_type3 = array( // query for first post type 'fields' => 'ids', 'post_type'=> 'type_3', 'showposts' =>30, 'orderby'=>'date' ); $type3_ids = get_posts( $args_type3 ); // join them $post_ids = array_merge($type1_ids, $type2_ids, $type3_ids); // start the main query $paged = (get_query_var('page')) ? get_query_var('page') : 1; $wp_query = new WP_Query(array( 'post_type' => array('type_1','type_2','type_3'),'post__in' =>$post_ids, 'orderby'=>'rand', 'showposts' => 25,'paged' => $paged)); if (have_posts()): while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
Second Step: Well then I determinated an hidden element, on the output, containing every single post ID. So assuming I’m on the isotope DIV “#container”, with every single element marked by “.element” class, I did this:
<div class="element"> <div class="check-id"><?php the_ID(); // every post ID ?></div> <h1><?php the_title(); // every post title ?> </div>
Third Step: finally I decided to use isotope options to manage new elements appending on the page. So with jquery I made a check for duplicate “text” contained by my “check-id” div. If positive I removed the element, else I added it.
That’s the part of jQuery used on my general Isotope function
<script type="text/javascript"> var $container = $('#container'); $container.infinitescroll({ navSelector : '#page-nav', nextSelector : '#page-nav a', debug:false, contentSelector : "#container", itemSelector : '.element', loading: { loadingText : "… Loading ...", finishedMsg: 'No more elements to load.', img: '<?php bloginfo('stylesheet_directory'); ?>/images/ajax-loader.gif' } }, function( newElements ) { $container.isotope( 'appended', $( newElements ) ); var seen = {}; $('.check-id').each(function() { var txt = $(this).text(); if (seen[txt]) $container.isotope( 'remove', $(this).parent('.element') ); else seen[txt] = true; }); } ); </script>
So that’s it! Thought It was good sharing ??
Forum: Fixing WordPress
In reply to: Random post order and pagination for a specific queryThank u so much for your answer, ubikus.
Indeed actually with your suggestion I can let it work only on the query with “rand” statement in my “orderby”.
Anyway I’m assuming that probably there will be some problems with the function instead, I thought was good and working, and it’s not.
In my pagination, I still have the issue that with randomization, my stream has the possibility to duplicate elements each step of my infinite scroll loading.
Just trying to figure it out a solution!
Thank you so much