How to get “last year from [spec year] that has posts”?

You could do a query for a single post made before the currently viewed year. When sorted by date in descending order (the default) the first result will be from the most recent year with posts. $current_year = get_query_var( ‘year’ ); $previous_posts = get_posts( array( ‘numberposts’ => 1, ‘date_query’ => array( ‘year’ => $current_year, ‘compare’ … Read more

Pagination for custom php code

<?php $pod = pods( ‘my_pod’ ); $params = array( ‘limit’ => 15 ); $pod->find( $params ); // Advanced Pagination echo $pod->pagination( array( ‘type’ => ‘advanced’ ) ); // Simple Pagination echo $pod->pagination( array( ‘type’ => ‘simple’ ) ); // Paginate echo $pod->pagination( array( ‘type’ => ‘paginate’ ) ); ?> From Pods documentation.

Duplicating Table of Contents for Paginated Post

You split post content into multiple pages with <!–nextpage–>, so you can use $page_number = get_query_var( ‘page’ ) to get current page number and global variable $numpages to get the number of pages in current post. Displaying table of content: global $numpages; $post_link = get_permalink(); $page_number = get_query_var( ‘page’ ); $toc = [ 1=>’Introduction’, ‘I2C … Read more

Paginate Pages by only showing 3 pages at most

Check the mid_size parameter in paginate_links mid_size: How many numbers to either side of current page, but not including current page. Default 2. So set it to: ‘mid_size’ => 1 Also you probably don’t want to show the first and last page, so set it to 0 (it’s 1 by default): ‘end_size’ => 0 Hope … Read more

Create A Loop With A Variable Number of Posts For Each Bootstrap Row?

The easy-but-a-bit-hacky way to get there would be to initialize a counter variable before your loop and then use that to tell what post you’re on. something like so: $paged = (get_query_var(‘paged’)) ? absint(get_query_var(‘paged’)) : 1; $args = array( ‘post_type’ => ‘workshop’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 11, ‘paged’ => $paged, ); $customQuery = new … Read more

Problem with parameters in url and pagination

Use remove_query_arg() function. DOCUMENTATION and EXAMPLES remove_query_arg( ‘message’ ) ; in pagination code like this. $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘base’ => remove_query_arg( ‘message’,get_pagenum_link(1) ) . ‘%_%’, ‘format’ => ‘page/%#%/’, ‘current’ => $current_page, ‘total’ => intval($total_patients / 10) + 1, ‘prev_next’ => true, ‘type’ => ‘list’, ));

Dropdown menu on custom page with product to choose number of products per page

Maybe this would work? function ps_pre_get_products_query( $query ) { $per_page = filter_input(INPUT_GET, ‘perpage’, FILTER_SANITIZE_NUMBER_INT); if ( ! is_admin() && is_woocommerce() && is_page() ) { $query->set( ‘posts_per_page’, $per_page ); } } I tested your code and the if statement didn’t seem to work with is_page() (but that could also be because my local WP sandbox is … Read more

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