Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)
  • Thread Starter Andrew

    (@snd26)

    I’ve tried different calculations for the offset using found posts in the calculation, but I can’t work it out.

    I use the WordPress custom loop to it’s fullest using $the_query = new WP_Query( $loop_args );
    So I will try and push infinite scroll to its limits 🙂 It is all working fine though except for that incorrect offset for my meta_query rating range. The date_query (which is similar to the meta_query parameter) which shows posts between a date range is working with the correct offset.

    I’m currently just using the infinite_scroll_query_args filter to get the correct offset for the rating range:

    // show events with at least a rating of 1
    function hp_jetpack_infinite_scroll_query_args( $args ) {
            $args['post_type'] = 'event';
    	$args['meta_query'] = array(
    	       array(
    			'key' 		=> 'rating_count',
    			'value' 	=> 1,
    			'compare' 	=> '>=',
    		)
    	);	
     
        return $args;
    }
    
    add_filter( 'infinite_scroll_query_args', 'hp_jetpack_infinite_scroll_query_args', 100 );

    Once I get that rating range working correctly, my full infinite scroll filter looks like this:

    function hp_jetpack_infinite_scroll_query_args( $args ) {
    
    	// defaults
    	$args['post_type'] = 'event';
    	$args['orderby'] = 'date';
    	$args['order']   = 'DESC';
    			
    	// User control loop Filters
    	if( hp_is_url_query_string() ) {
    
    		// Type (post type)
    		if( hp_query_string( 'type' ) ) {
    			$args['post_type'] = hp_get_sanitized_url_query_string_type_value();
    		}
    			
    		// Search term
    		if( hp_query_string( 's' ) ) {
    			$args['s'] = get_search_query();
    		}
    		
    		// Event category (taxonomy)
    		if( hp_query_string( 'event_category' ) ) {
    			$args['event_category'] = hp_get_sanitized_url_query_string_event_category_value();
    		}
    
    		// Order by date posted
    		if( hp_query_string( 'orderby', 'newest' ) ) {	
    			$args['orderby'] = 'date';
    			$args['order']   = 'DESC';
    			
    			// bug fix
    			$paged = (int)$_POST['page'] + 1;
    			$args['paged'] = $paged;
    		}
    		
    		// Order by comment count
    		if( hp_query_string( 'orderby', 'comment_count' ) ) {	
    			$args['orderby'] = 'comment_count';
    			$args['order']   = 'DESC';
    			
    			// bug fix
    			$paged = (int)$_POST['page'] + 1;
    			$args['paged'] = $paged;
    		}
    		
    		// Order by Rating
    		if( hp_query_string( 'orderby', 'rating' ) ) {	
    			$args['meta_key'] = 'rating_count';
    			$args['orderby'] = 'meta_value_num';
    			$args['order']   = 'DESC';
    			
    			// bug fix
    			$paged = (int)$_POST['page'] + 1;
    			$args['paged'] = $paged;
    		}
    		
    		// Order by view count
    		if( hp_query_string( 'orderby', 'view_count' ) ) {	
    			$args['meta_key'] = 'view_count';
    			$args['orderby'] = 'meta_value_num';
    			$args['order']   = 'DESC';
    			
    			// bug fix
    			$paged = (int)$_POST['page'] + 1;
    			$args['paged'] = $paged;
    		}
    
    		// Date range
    		if( hp_query_string( 'after' ) || hp_query_string( 'before' ) ) {
    			$args['date_query'] = array(
    				array(
    					'after'     => hp_get_sanitized_url_query_string_after_value(),
    					'before'	=> hp_get_sanitized_url_query_string_before_value(),
    				)
    			);
    		}
    
    		// rating range - Bug, incorrect offset
    		if( hp_query_string( 'rating' ) ) {
    			$args['meta_query'] = array(
    				array(
    					'key' 		=> 'rating_count',
    					'value' 	=> hp_get_sanitized_url_query_string_rating_value(),
    					'compare' 	=> '>=',
    				)
    			);
    		}		
    	}
     
        return $args;
    }
    add_filter( 'infinite_scroll_query_args', 'hp_jetpack_infinite_scroll_query_args', 100 );

    I now know there is at least 2 things that is affecting the offset of my meta_query rating range:

    1. the posts_per_page set in admin. If I set this to 1 post per page, there will be no offset which means I can use the same bug fix used on the orderby parameter.

    2. The other thing affecting the offset is the total posts of the post type (not the found posts).
    So if the wp_count_posts( 'your_post_type' )->publish is much higher than the: $wp-query->found_posts; There will be no offset, which means I can add the same bug fix used on the orderby parameter.

    I don’t know if you can work out a fix for this based on this information.

    • This reply was modified 9 years, 5 months ago by Andrew.
    Thread Starter Andrew

    (@snd26)

    Thanks, that worked. 🙂

    Thread Starter Andrew

    (@snd26)

    Thanks.

    Looks like this is the best option for it:

    <ul class="pagination">					
    	<li class="nav-previous"><?php previous_posts_link( 'Previous posts' ); ?></li>
    	<li class="nav-next"><?php next_posts_link( 'Next posts', $the_query->max_num_pages ); ?></li>
    </ul>
    • This reply was modified 9 years, 7 months ago by Andrew.
    Thread Starter Andrew

    (@snd26)

    OK. Thanks. I’ve been using it for a few days since switching to this version. It’s all good. The scope filter works fine too.

    .

    Thanks. I’m using this filter and the developmental verion.

    Thread Starter Andrew

    (@snd26)

    I’ve had a look at https://github.com/r-a-y/buddypress-followers/wiki/Create-your-own-follow-activity-loop

    if ( bp_has_activities( array(
    // change the user ID below to whatever
    ‘user_id’ => bp_get_following_ids( ‘user_id=3’ )
    ) ) ) :

    How would I write this so it displays activity items from all users that a user is following?

    Thread Starter Andrew

    (@snd26)

    Thanks Ipstenu, I’ll look into that.

    Thread Starter Andrew

    (@snd26)

    I read somewhere, if an admin panel is compromised a hacker can upload a plugin with malicious code. So adding DISALLOW_FILE_MODS prevents that.

    I don’t want to disable the update notifications, I want to keep them to notify me when new updates are available, I am just making sure that define( ‘DISALLOW_FILE_MODS’, true ); doesn’t disable the update notifications.

    All my uploads go in a ‘media’ directory:
    http://domain.com/media

    just by adding in wp-config:
    define( ‘UPLOADS’, ‘media’ );

    based on: http://codex.ww.wp.xz.cn/Editing_wp-config.php

    I have had this for a while and works fine and you don’t have to change anything in the database.

    To put uploads in a subdomain I think you’ll have to add something like this in wp-config.php:

    define(‘UPLOADS’, ‘http://img.domain.com&#8217;);

    – remember to add it before the line that says /* that’s all happy blogging */
    and make sure your new ‘img’ folder is writable.

    You may like to check with someone else because I haven’t tested putting the uploads in a subdomain.

    Thread Starter Andrew

    (@snd26)

    That’s understandable, perhaps this question was more appropriate for another forum if it is more of a general internet question – but I was unsure.

    “You have to buy a cert for each domain.”

    So, (apologise if this seems an obvious question to you) if a user maps a domain, they won’t be able to access the admin/login securely? But this was why I asked if it is possible to force the admin side to use the subdomain instead of the mapped domain so the user will at least benefit from my wildcard cert in the admin. (if that makes sense).

    Remove the ‘test’ subdomain.

    As Bet Hannon said – if you can create wildcard subdomains, all you need to do is add an asterisk (*) as the subdomain.

    You can’t. That editor you’re talking about will make changes directly to the CSS file for that theme, so only the network admin should be making them sort of edits. You can however use a plugin that allows each subsite user to add CSS to overide the theme styles.

    There are a couple of good ones:
    https://ww.wp.xz.cn/plugins/simple-custom-css/
    just install this plugin and each subsite can add css to overrule the current theme styles in settings > add css.

    Or the CSS module on the Jetpack plugin – But the Jetpack plugin comes with a lot of modules and it needs connecting to wordpress.com. I forked the jetpack CSS module because I like it the best, see more about the jetpack CSS module here:
    http://jetpack.me/support/custom-css/

    Thread Starter Andrew

    (@snd26)

    I have just noticed the same happens on wordpress.com websites after looking at a few sites in their showcase, example:

    qz.com – works fine
    https://qz.com/ – exact same insecure error as me

    That surprised me. so I have three questions about this.

    1. If I only make https appear in the admin (by using just the wp-config SSL define) I still don’t know how a user with a mapped domain would login to their admin (which will be https). So for example:
    mapped-domain.com – is fine
    but when I click on the top toolbar admin link to go to the admin:
    https://mapped-domain.com/wp-admin – the https insecure error occurs. So how would the site administrator, for the site above (qz.com) get into their admin: https://qz.com/wp-admin ? I assume it needs to be somehow setup so when a user with a mapped domain goes to their admin, it goes to the original sub domain:
    admin: https://site.mysite.com/wp-admin
    frontend: mapped-doman.com
    how would I do that?

    2. But if possible, I would still prefer to keep https everywhere (frontend and admin), by forcing https with htaccess. So is it possible to have https on mapped-domains everywhere?

    3. If my second question isn’t possible, would it be possible to set it up how wordpress.com has it for their users sites, so https is everywhere, example:
    https://sundoglitblog.wordpress.com/
    But all sites with mapped-domains do not have https like the qz.com site above? providing I know the answer to my first question.

    Hope all that made sense. Any help super appreciated.

    Thread Starter Andrew

    (@snd26)

    I bought a wildcard SSL certificate from my host:
    http://www.siteground.com/ssl_certificates.htm

    The actual name of it on my account says ‘Alpha SSL Certificate’, so I believe it was a resell of this one:
    http://www.alphassl.com/ssl-certificates/wildcard-ssl.html

Viewing 15 replies - 1 through 15 (of 29 total)