WordPress Blog has an infinite redirect loop
Try using this in your header: <?php if( ! is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit(); }
Try using this in your header: <?php if( ! is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit(); }
Not sure how dramatic this’ll be, but it should improve nontheless: <?php /** * You can try forcibly splitting the query (grabbing IDs *then* all fields) * Works well for large post results. (available WP 3.4+) */ add_filter( ‘split_the_query’, ‘__return_true’ ); $posts = get_posts( array( ‘post_type’ => ‘listings’, ‘posts_per_page’ => -1, /* Disable term caching … Read more
It make use of global variable $post to get author id of current post. Using that this function returns the author url. Note – Make sure you put this in condition ( is_single() ) so it only print author url on single.php. <?php echo get_author_posts_url( $post->post_author ); ?> Update – <?php $username = get_userdata( $post->post_author … Read more
get_query_var(‘paged’) should be get_query_var(‘page’), however, you should use a pre_get_posts action hook to alter the query rather than using query_posts in the template, which is a waste of resources (see this answer for more info).
In functions.php function my_theme_navigation() { global $shortname; if( get_option( $shortname . ‘_next_prev_or_paginate’ ) == ‘Next’ ) : // the block for next-prev navigation echo ‘<div style=”float:left”>’; next_posts_link(‘Older’); echo ‘</div>’; echo ‘<div style=”float:right”>’; previous_posts_link (‘Newer’); echo ‘</div>’; else : // the block for pagination global $wp_query; $big = 999999999; // need an unlikely integer echo paginate_links( … Read more
In your template, the add_action you have there is way too late because by the time WordPress gets to your template, the query has already been performed. If this is for a category page, I’d do the following in your functions.php: //Display Gaming Trailers function display_gaming_trailers( $query ) { if ( $query->is_category() && $query->query_vars[‘category_name’] == … Read more
If you are using post_class() in your content template like this … <div <?php post_class(); ?>> … you can filter that and add a special class: add_filter( ‘post_class’, ‘mark_first_post’ ); function mark_first_post( $classes ) { remove_filter( current_filter(), __FUNCTION__ ); $classes[] = ‘first-post’; return $classes; } Your first post in a loop will now have the … Read more
Track the IDs, and “exclude” them with post__not_in. It is hard to tell exactly what does what with the disjointed way you posted your code but the general case solution is .. $c_posts = new WP_Query(“showposts=10”); $tracker = array(); if ($c_posts->have_posts()) { while ($c_posts->have_posts()) { $c_posts->the_post(); $tracker[] = get_the_ID(); // more code } } $other_loop … Read more
I would filter pre_get_posts. function allow_pending_posts_wpse_103938($qry) { if (!is_admin() && current_user_can(‘edit_posts’)) { $qry->set(‘post_status’, array(‘publish’,’pending’)); } } add_action(‘pre_get_posts’,’allow_pending_posts_wpse_103938′); That should show pending posts to your editors for all of your queries on the front end. You can, of course, restrict is more if you’d like. I’d add some code to mark the pending posts so your … Read more
An alternative way is putting the unwanted pages in an array. Useful for storing them in a option or in a serialized custom field. $exclude_pages = array(‘music’, ‘contact’); // can be something like this: $exclude_pages = get_option(‘exclude_pages’); if ( have_posts() ) : while ( have_posts() ) : the_post(); if ( is_page() && ! empty($exclude_pages) && … Read more