What’s not working? The number of posts per page or the pagination links? The pagination links seem to be handled by “my_pagination()”, what is the code used for that function? (please use pastebin.com for sizable code snippets and simply provide a link here. Directly embedding short snippets is fine though)
Thread Starter
berez
(@berez)
Links are working, the page moves to the next, but the posts on this page are the same. That is the page switch positions but displays the same as on the first page. If you do not set this page as your home page, then it works.
This code of my pagination
This code of my custom posts page
Thank you very much if you could help me! A good site http://pastebin.com
This is working page https://berezovsky.org.ua/myblog/%D1%88%D0%B0%D0%B1%D0%BB%D0%BE%D0%BD-%D1%81-%D1%81%D0%B0%D0%B9%D0%B4%D0%B1%D0%B0%D1%80%D0%BE%D0%BC/
But if you put as the main page ….
Thank you for posting your code on pastebin. The syntax highlighting makes code much easier to read. Everything looks good, there is no problem with your code.
I believe I understand the problem now. It may be a misunderstanding of the various settings on the Reading Settings Screen. Since your screen is probably not in English, it may help to refer to a English Language Screen Image, though you obviously speak English very well.
From what you posted so far, I understand you selected “A static page” option under “Front page displays”. Under that you’ve selected a page which uses the template you’ve shared as “Front page”. And not as “Posts page”, is this correct?
If correct, the behavior is by design. The Front page setting is for displaying a single static page. Apparently no matter what you try to do with pagination, it displays the same. This is news to me as well. For your situation, you should leave the Front page selection unselected and select your page with the Posts page selection. You will see this selection only lists pages to select, just like the front page select.
If you read the description of each option below the image, this arrangement makes sense once you know the situation. But on first reading, it is easy to not understand it correctly.
If I’ve not understood your situation correctly, my apologies. Please tell where I’m wrong and I’ll reconsider your problem. I hope things are more clear and your problem is solved. Cheers.
Thread Starter
berez
(@berez)
I selected a page which uses the template you’ve shared as “Front page”. And not as “Posts page”,this is correct 🙂 my Engish is poor… very thanks – Google Translator 🙂
Look – Screenshot Custom page as Front Page. This is code Custom Page
Look here how this working
my Engish is poor… very thanks – Google Translator 🙂
Fooled me! 😀 Usually Google translate syntax is very bad, but it does well from your language to English. It works well for conveying general ideas, but is terrible for specific instruction. But let us try anyway 🙂
Change your settings to look like this screenshot. This should make your site work as you desire.
Thread Starter
berez
(@berez)
It does not work on the front page shows a standard template index.php
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }
query_posts( array( 'paged' => $paged ) );
‘page’ works on static front page. That is the truth of this hack 🙂
Thread Starter
berez
(@berez)
🙁 It works. But again, I have the page as the home page, and now even post does not show, shows normal page.php
I have this code on static front page – it works.
Try to add wp_reset_query(); exactly above this lines.
Thread Starter
berez
(@berez)
I was told that
“Never use query_posts. Very likely that’s what breaks the pagination. Use WP_Query` instead.”
But I did not get to do the loop and show article with this function
Thread Starter
berez
(@berez)
Show Posts from Current Page
Display posts from current page:
$query = new WP_Query( array( 'paged' => get_query_var( 'paged' ) ) );
Display posts from the current page and set the ‘paged’ parameter to 1 when the query variable is not set (first page).
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query = new WP_Query( array( 'paged' => $paged ) );
Pagination Note: Use get_query_var(‘page’); if you want your query to work in a Page template that you’ve set as your static front page. The query variable ‘page’ also holds the pagenumber for a single paginated Post or Page that includes the <!–nextpage–> Quicktag in the post content.
Display posts from current page on a static front page:
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$query = new WP_Query( array( 'paged' => $paged ) );
And what can i use this samples with loop???