How do I rewrite this loop as a new WP_Query style-loop?

You’re 95% of the way there already. Just add if ( $my_query->have_posts() ) and incorporate your $odd variable: <?php $my_query = new WP_Query(‘offset=5&showposts=10’); if ( $my_query->have_posts() ) : $odd = false; while ($my_query->have_posts()) : $my_query->the_post(); $odd = !$odd; ?> <div class=”<?php if ($odd) echo ‘uneven ‘; ?>post”> <h3><a href=”https://wordpress.stackexchange.com/questions/70713/<?php the_permalink(); ?>”><?php the_title(); ?></a></h3> <?php the_excerpt(); … Read more

Comments offset

<?php global $wp_query, $post; $comments_arr = $wp_query->comments; $comments_arr = sort( $comments_arr); $comments_arr = array_pop( $comments_arr ); $comments_arr = usort($comment_arr, ‘comment_comparator’); $comment_count = get_comment_count($post->ID); ?> <h3 id=”comments-title”><?php printf( _n( ‘One Response to %2$s’, ‘%1$s Responses to %2$s’, get_comments_number(), ‘YOUR_THEMES_TEXTDOMAIN’ ), number_format_i18n( get_comments_number() ), ‘<em>’ . get_the_title() . ‘</em>’ ); ?></h3> if ( have_comments() ) : ?><ul … Read more

Missing image in gallery shortcode in custom feed

The problem was in additional symbols &#8221 in $attr[‘ids’] array. So I’ve changed: $atts[‘include’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘include’]); $atts[‘orderby’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘orderby’]); $atts[‘order’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘order’]); $atts[‘exclude’] = str_replace(array(“&#187;”,”&#8243;”,”&#8221;”), “”, $atts[‘exclude’]); And now everything ok.

WP_Query, pre_get_posts and offset

It helps to write problems down. After I haven’t used pre_get_posts extensively, I focused too much on that area for the cause, but it was the if clause. Changed to if ( ! is_admin() && $query->is_main_query() && ! is_post_type_archive( ‘cpt’ ) ) { return $query; } elseif ( ! is_admin() && $query->is_main_query() && is_post_type_archive( ‘cpt’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)