Altering next_posts_link(); and previous_posts_link();

I searched little and did this which is working. add_filter(‘next_posts_link_attributes’, ‘posts_link_attributes_1’); add_filter(‘previous_posts_link_attributes’, ‘posts_link_attributes_2’); function posts_link_attributes_1() { return ‘data-hover=”Next” class=”your class here”‘; } function posts_link_attributes_2() { return ‘data-hover=”Previous” class=”your class here”‘; }

WordPress wp_link_pages show only next/prev link

I’m not sure why it’s not working. Did you try with the defaults but only changing the “page” and clearing the before/after? wp_link_pages( array( ‘before’ => ”, ‘after’ => ”, ‘link_before’ => ”, ‘link_after’ => ”, ‘next_or_number’ => ‘next’, ‘separator’ => ‘ ‘, ‘nextpagelink’ => ‘Next page’, ‘previouspagelink’ => ‘Previous page’, ‘pagelink’ => ‘%’, ‘echo’ … Read more

How can I show a multipage post as a single, wrapped post?

Since it looks like there’s no existing way to do this, here’s my solution. It just splits the content on the pagebreak tag, parses the HTML and wraps each page in a div: function get_paginated_post($post) { $pagebreak = ‘<!–nextpage–>’; $raw_post = $post->post_content; $pages = explode($pagebreak, $raw_post); $html=””; foreach ($pages as $p=>$page) { $html .= ‘<div … Read more

Customize WordPress Core Template

Since it isn’t pluggable, you could define a replacement function in your theme. In your theme’s functions.php file, copy the core paginate_links() function, rename the function – perhaps my_paginate_links(), modify the source code so it creates the anchor tag you need, and then call your new function wherever you need it in the rest of … Read more

Pagination url canonical problem

You have to install Yoast SEO and then add to functions.php: function return_canon () { $canon_page = get_pagenum_link(1); return $canon_page; } function canon_paged() { if (is_paged()) { add_filter( ‘wpseo_canonical’, ‘return_canon’ ); } } add_filter(‘wpseo_head’,’canon_paged’);

Using Pagination with Timber Routes

After some messing around (and actually looking at the docs properly!) I have solved the problem. In my routing, I just need to add another map to handle paging with my custom routing: Routes::map(‘items/browse/:field/:value’, function($params) { $query = array( ‘post_type’ => ‘item’, ‘meta_key’ => $params[‘field’], ‘meta_value’ => $params[‘value’] ); Routes::load(‘archive-item.php’, $params, $query); }); Routes::map(‘items/browse/:field/:value/page/:page’, function($params) … Read more

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

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

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