Undefined offset: 1

The problem is that $Exploded_slug[1] is empty, don’t forget that arrays are 0-based. So you need to change your query. Also it is preferred to use lower case for regular variables like yours, so I’d also change $Exploded_slug to $exploded_slug. Here’s the code: $exploded_slug = explode($user->ID.’–‘, $url_slug); $query = “SELECT comments FROM wp_rdp_winners WHERE id … Read more

myprefix_adjust_offset_pagination’ not found

I could be wrong here, but you’re calling a function “myprefix_adjust_offset_pagination” with the add_filter option, but you’re not actually making that function unless it’s on the homepage as that function is created behind the if is_home statement. This would explain why you get the error on your admin page. Try pulling that function out, or … Read more

How to calculate post index when using offset in custom query

In your case, count would be offset + current_post: $my_query = new WP_Query( array( ‘post_type’ => ‘colors’, ‘posts_per_page’ => 5, ‘offset’ => 2 ) ); if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) : $my_query->the_post(); echo $my_query->query_vars[‘offset’] + $my_query->current_post; the_title(); endwhile; endif; wp_reset_postdata();

Get the index of post outside the loop

The problem of your code is that $wp_query is a global variable. Once the sidebar is loaded via a function (dynamic_sidebar) you need to globalize that variable before use. However, once you are in the single view the current_post is always 0. You have to run another query, loop it, and check the every post … Read more