pagination for a custom query
pagination for a custom query
pagination for a custom query
The error is in the syntax; there’s a semicolon after the if condition. Try this: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0): ?> test <?php endif; ?> Alternative PHP syntax: <?php $page_comment = get_query_var(‘cpage’); if ($page_comment > 0){ ?> test <?php } ?>
It turned out these erroneous links were generated by Facebook Feed WD plugin. Searching the code for phrases such as page_number_0 didn’t turn up any results, as the code in question was imported from outside the server, and switching to the default theme gave a red herring because it hid the widget and fixed the … Read more
Don’t create a new query. You can use pre_get_posts for this type of works. Example : If you want to add books and movies custom post type to home page main loop, function books_movies_cpt_in_home($query) { if ($query->is_home() && $query->is_main_query()) { $query->set(‘post_type’, array(‘books’,’movies’)); } } add_action(‘pre_get_posts’, ‘books_movies_cpt_in_home’);
function eg_add_rewrite_rules() { global $wp_rewrite; $new_rules = array( ‘(tur|tip|tedarikci|beden|mevsim)/(.+)/?$’ => ‘index.php?post_type=urun&’ . $wp_rewrite->preg_index(1) . ‘=’ . $wp_rewrite->preg_index(2) ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action( ‘generate_rewrite_rules’, ‘eg_add_rewrite_rules’ ); I had this rewrite rule in my functions php. This was overwriting page variable. So i added one more rewrite rule to handle page variable. Here is … Read more
<!DOCTYPE html> <html> <head> <style> ul.pagination { display: inline-block; padding: 0; margin: 0; } ul.pagination li {display: inline;} ul.pagination li a { color: black; float: left; padding: 8px 16px; text-decoration: none; transition: background-color .0s; border: 1px solid #aaa; } ul.pagination li a.active { background-color: #f88017; color: white; border: 1px solid #000000; } ul.pagination li a:hover:not(.active) … Read more
For posterity’s sake, it was enough to call the global $wp_query variable right at the top of the split_posts() function, like this: function split_posts($Query, $infinite = false) { global $wp_query; $temp_query = $wp_query; $wp_query = NULL; $wp_query = $Query; … } Cheers!
Stop overriding the default loop and use pre_get_posts instead. Like this: function wpse_247208_custom_category_query( $query ) { // Return early for any situation you aren’t interested in. if ( is_admin() || ! $query->is_main_query() || !is_category() ) { return; } $query->set( ‘posts_per_page’, 6 ); // Don’t use a global; create a function to populate this value // … Read more
The functions next_post_link() and previous_post_link() have the parameters $in_same_term and $taxonomy for that purpose.
re 2. two loops, one pagination link: remove the individual paginations; add this at the end: $max = max($ideas_query->max_num_pages,$opinions_query->max_num_pages); if (function_exists(‘custom_pagination’)) { custom_pagination($max,””,$paged); }