WordPress 101 - Part 13: Create and manage the Pagination in your blog loop

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 172

  • @markwaters5964
    @markwaters5964 9 ปีที่แล้ว +1

    Another great tut. Thanks for taking the time creating this series. Very beneficial

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      Mark Waters Thank you for following my tutorials!

  • @jamesfrazier9318
    @jamesfrazier9318 8 ปีที่แล้ว +2

    You are an amazing instructor! This was killing me filtering through WP forums and Googling. Nothing as great as this. Thank you!

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Glad you found my tutorials :D

  • @vladbukov5660
    @vladbukov5660 9 ปีที่แล้ว +2

    Thanks you for this great video. This is best tutorials about creating wordpress themes from scratch for BD. I have one question. You edit subtitles? I do not live in an English speaking country and subtitles very helping me and like me. Unfortunately, automatic subtitles can not cope on their own and in translating subtitles sometimes get nothing. Please edit it, maybe I'm not the only one who need in this . Thank you for your lessons!

  • @darkbernart81
    @darkbernart81 8 ปีที่แล้ว

    First thank you very much for these awesome videos. And watching this video I had a question. I have a portfolio page with a filterable animated portfolio where I sort it with get_terms function, then when I do a link in a custom post , it appears to single-portfolio file where I can paginate one to one all custom posts of portfolio with these pagination functions. I would like to know how I can paginate posts with a specific term, Should I create a single file with every term? or it does idependents archive files?. Sorry my english is very bad

  • @mallix-011
    @mallix-011 8 ปีที่แล้ว +1

    Thank you! Was really struggling to figure out why my pagination wasn't working. This tutorial was a great help.

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Happy to be helpful!

  • @gidikremer
    @gidikremer 9 ปีที่แล้ว +1

    thank you very much for the videos, I am going through them all and I am very pleased with your thorough explanations.
    I would very much like it if you can make another video showing how to create a numeric pagination- meaning displaying the number of pages and enabling users to skip to a certain page..
    please, I will be very greatful (already am.. but I'll be even more so :)

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +gidikremer Hi, thanks for your comment.
      I will tackle a pagination in an upcoming tutorial for the advanced series. I'm building a premium Blog theme and I will create both options of pagination or lazy load with ajax.
      Thank you for following!

  • @uzzaldey8616
    @uzzaldey8616 9 ปีที่แล้ว +1

    Thanks for your new tutorial. Your tutorials are very effective for very beginner. I have seen the other 12 tutorials. I am very beginner in word press theme development and I am not good in PHP (have a very basic notion). Would you please suggest me how can I develop myself? I am very beginning stage.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      uzzal dey Hi and thanks for your comment!
      I was in your same situation 12 years ago, but with the difference that sources and tutorials were really hard to find.
      Now it's pretty easy to find a good course and an infinite amount of free resources.
      I suggest you to take a look at the TUTS+ website, is full of tutorials and really nice resources.
      Other than that the suggestion that I want to give you is "Keep trying, never stop learning and never feel satisfied. Always push yourself a little bit more. Practice, practice, practice."
      It's not an easy path and it's a long process, but if you keep doing it everyday you will achieve something incredible everyday and the joy of building your own applications is amazing.
      Oh, by the way, I'm gonna start a LAMP development series for beginners, soon :D

    • @uzzaldey8616
      @uzzaldey8616 9 ปีที่แล้ว +1

      Alessandro Castellani thanks for your directional suggestion and inspiration. I am trying to learn from everywhere.Sometimes I may insist you to learn something . Please help me at that time.

  • @bimaldimri8817
    @bimaldimri8817 8 ปีที่แล้ว +1

    nice tuts. Very helpful. I am having some issues with pagination on custom post types and permalinks. Do you have any tutorial/s to address the problem?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +bimal dimri Custom post types are exactly like regular posts, so the pagination should work with same functions and methods. What kind of issues are you experiencing?

    • @bimaldimri8817
      @bimaldimri8817 8 ปีที่แล้ว

      The next and previous posts link return a 404 page error when i enable permalinks with %postname% option. here is my post inwordpress forum wordpress.org/support/topic/404-page-not-found-error-with-pagination-and-permalinks-on-custom-post-type

  • @SuperMa06
    @SuperMa06 6 ปีที่แล้ว

    I have a question: in the line:
    $currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
    In case of main blog page, get_query_var will return 0, so in this case the above line will set currentPage to 1, and in case of page 1 it will also be set to 1?
    How does WordPress Differentiate between the two cases so that it displays the correct posts?
    Thanks.

  • @DanielEliasKana
    @DanielEliasKana 9 ปีที่แล้ว +1

    Thank you Alessandro for this amazing tutorial, i'm learning a lot, and trying to change some code, how i can invert the direction of pagination? i mean older posts at right and newer posts at left, and previous post at right and next post at left.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Daniel Elias Sure, you can invert the scripts and change the location with CSS. I think I did something like that in one of the next videos, or during a Live Development session.
      Happy Coding!

  • @esads.4290
    @esads.4290 5 ปีที่แล้ว

    Which videos do i have to watch to get the design like this?

  • @inventive-pulse
    @inventive-pulse 2 ปีที่แล้ว

    WHAT IS THE DIFFERENCE BETWEEN WP_Query AND query_posts confused between these two. Which one to use and when. Pls explain.

  • @jellycoding
    @jellycoding 9 ปีที่แล้ว +1

    Not a big thing, but how did you do the arrow at 4:35?

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +2

      +jellycoding I copied the « symbol from an ASCII table from here: www.ascii.cl/htmlcodes.htm

  • @kavyawasim6226
    @kavyawasim6226 8 ปีที่แล้ว +1

    Hi Alessandro, your teach like a pro.... Well I was wondering how would I show pagination links in case of custom post type? can you please give me a little tip ??

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Tanvir Khaan Hi, thank you so much.
      The pagination tutorial should work for both standard post loop, and custom post type based loops.
      Did you tried? Does it work for you?

    • @kavyawasim6226
      @kavyawasim6226 8 ปีที่แล้ว

      Nope.....unfortunately...in codex i found that in case of custom post type or showing it in different page then home/index/bla bla they want me to use some codes at the top and bottom...like this...,




      I found it on internet...Then it worked but it looks ugly you know...and still i dont know why I have to use query() ....do you have better solution or its just universal kinda thing ...?? Thank you........

  • @bahmedBoussada
    @bahmedBoussada 7 ปีที่แล้ว +1

    Thank you Alessandro best explaining for beginners,
    query_posts() stil has a problem with categories page an we can resolve it by the same way get_query_var('cat').

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Awesome, thanks for sharing :D

  • @cleanview8324
    @cleanview8324 8 ปีที่แล้ว

    Thanks for nice tutorials; have you any tutorials of numbering Pagination like 1,2,3---- etc

    • @andoy_abarquez
      @andoy_abarquez 8 ปีที่แล้ว

      as per reading comments below, your concern is covered and implemented in the "Sunset Theme" :)

    • @mikenuttall
      @mikenuttall 8 ปีที่แล้ว

  • @holalabellebille
    @holalabellebille 7 ปีที่แล้ว

    hello, fantastico, grest job you are doing !
    a little problem for me :
    in settings / reading i put 3 last articles
    but i noticed that as soon as i rewrite the WP_Query() before the Loop, for example if i want a certain category, like :
    $lastBlog = new WP_Query('type=post&category__in=6');
    LOOP here
    i can see the last 3 posts from cat 6 ok, but pagination is not working (i still have post 1, 2, 3, but can never see posts 4, 5, 6)
    and pagination links always appear even if i have only 8 posts in cat6 i can reach page/35
    i am certainly doing something wrong !
    Cheers and hello from Paris.

  • @gurpreetsingh5384
    @gurpreetsingh5384 9 ปีที่แล้ว +1

    Sei un grande!!! grazie mille Alesandro.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Gurpreet Singh Ahahaha, thank you so much, perfect Italian :D

  • @siddheshshinde5598
    @siddheshshinde5598 6 ปีที่แล้ว

    hello sir i did same as you did in this video but my page navigation link not shown or not visible on single.php but works on post . pls help me why this not working on single.php

  • @ralomotey
    @ralomotey 8 ปีที่แล้ว +1

    Hey Alessandro, question for you, what about numbered pagination ?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      I will implement that in my Sunset theme, during the Premium Theme Development series.
      Cheers

  • @sermonday
    @sermonday 9 ปีที่แล้ว +1

    thanks Aless. please how can we use wordpress comment to be on a link, that wen the link is clicked on it will then take u to a separate page that is mainly for commenting and see all the comments for that specific post.

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +1

      lontfull Thank you for following.The quick and dirty solution would be to create a single.php template with no content but just the comment template. It's a bit more complicated than that and it'll take me too long to answer here. I will soon do another Live Development session where you can join and ask me to solve this problem. Cheers.

  • @VasilisKar
    @VasilisKar 8 ปีที่แล้ว +1

    Thank you Aless. Cosmos bless you.

  • @bakinto
    @bakinto 7 ปีที่แล้ว +1

    I wish you expalined the ordred pagination too or uses bootsratp pagination, awesome work, thanks a lot :D

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      I think I did if I remember properly, exactly with bootstrap.

  • @edwardsolon168
    @edwardsolon168 7 ปีที่แล้ว +1

    Alessandro, Buddy, I'm reviewing these Great Tutorials and enjoy them even more, BUT,..hey, you/we, went through all the trouble to create a 1,2,3 pyramid(6 total) and then you set pagination to 3, lobbing off the bottom row. No Biggie, it's just that as I was reviewing it, i was wondering why that last row wasn't being used; Where'd it go ? And the reason was to show pagination controls in the next lesson, this one..oh, well. Thanks Again for sharing this knowledge with us. Can't wait to move on to your advanced tutorials...
    Eddie in Dallas

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Thanks for watching them all :D

  • @irfanhaider2598
    @irfanhaider2598 8 ปีที่แล้ว +1

    Best Tutor, I like it (y) , god bless you.

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Thank you so much!

  • @solomonmanalili8965
    @solomonmanalili8965 8 ปีที่แล้ว +1

    Hi, Is this only available in index.php? Because I'm trying to put it in my page template where I put my tons of posts but it seems the doesn't work. please help

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Solomon manalili Yes, it definitely works also with custom queries, not only on the index.php.
      Are you using it before the wp_reset_postdata(); ?

    • @solomonmanalili8965
      @solomonmanalili8965 8 ปีที่แล้ว

      +Alessandro Castellani Hi, I got the pagination now in my page template but now I'm having problem with the single.php posts now. I have different categories and I have 3 single.php templates. the problem is that the pagination is including all the categories instead of the specific category that i want. for example. in my one single.php template I only want to paginate the "Services" category but it also paginate the other categories. please help me.

  • @hafeefkt07
    @hafeefkt07 9 ปีที่แล้ว

    Thank you for the video sir,
    I created one category in posts and i add some posts. i displayed it by placing short-code in particular page that i created in my admin-->pages. i tried to set the post_per_page in settings--> reading but its not work for me. So i set the page_per_post in short code, but pagination is not working. Also i tried to add page break after the short-code. But no use because it break after all my posts. how can i add pagination in posts ? i hope you will help me

  • @bigulinis
    @bigulinis 6 ปีที่แล้ว

    I have a problem with displaying next and previous buttons for posts. If I use a custom query with WP_Query inside index.php, i can see the posts with my navigation links (prev and next) at the bottom. But if I use the same exact code inside a template, and make my "about" page to use that template, it doesn't show the navigation links.

    • @bigulinis
      @bigulinis 6 ปีที่แล้ว

      No matter where i try to use the "next_posts_links" and "previous_post_links" outside the index.php, it won't work. Even if I make a specific page-about.php and copy-paste the code from index.pxp, still doesn't show the navigation link. The code only works on index.php.

    • @bigulinis
      @bigulinis 6 ปีที่แล้ว

      i even try this and still doesn't work:

  • @darrenbachan9272
    @darrenbachan9272 8 ปีที่แล้ว +1

    How can I spit out the number of pages in between the previous/next links?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      You can access the global variable in your pagination with this function: get_query_var('paged'), and echo it.

    • @darrenbachan9272
      @darrenbachan9272 8 ปีที่แล้ว +1

      I'm a super newb at php and WordPress, any chance you have a video on this?

  • @emiliorodrigoparra1387
    @emiliorodrigoparra1387 9 ปีที่แล้ว +1

    Hello and Thanks for your amazing tutorials!! ^^ I'm a new follower and I think you are a great teacher, a lot of times while watching a video I think.."How about If...?" and seconds later you explain it, feel like you can read minds xD. I have a small question about you environment, is there an special plugin or package you use to get that autocomplete wordpress functions? I have Windows so I'm using Atom not Coda, but the Wordpress API Plugin that I have installed gives me the autocomplete but not the placeholders like you inside the php functions, I find them super helpful and I'm trying to find out how could I get them...
    Thanks a lot again for your time and for helping begginers :D

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      +Emilio Rodrigo Parra Hi, thank you so much for your amazing comment, I'm really happy my mind reading powers are still working :D
      I don't know if Atom has a plugin or extension like the one I'm using. I suggest you to try SublimeText or Brackets. Both are free and have a lot of plugins and extensions, where you should be able to find something similar, or even better than Coda.
      Happy Coding!

    • @emiliorodrigoparra1387
      @emiliorodrigoparra1387 9 ปีที่แล้ว

      +Alessandro Castellani Coda does the autocomplete without any extension or plugin?

  • @british_berk2337
    @british_berk2337 8 ปีที่แล้ว

    I don't understand the function of the content-aside.php, content-image.php etc files if the single.php now creates the content for individual blog posts. Do they have any use other than to help filter specific types of posts in the Wordpress admin panel?
    Loving the tutorials, very easy to follow and understand! Keep up the great work :)

    • @b0sStAB
      @b0sStAB 8 ปีที่แล้ว

      I was wondering too, it seems that if we create a single.php file, everything points to that page? because I have created content-aside.php and content-image.php, it doesn't use that template but it points to single.php.

    • @b0sStAB
      @b0sStAB 8 ปีที่แล้ว

      I get it now, the content-aside, content-image is how you would like your content show up in your posts page.

    • @HansKr
      @HansKr 8 ปีที่แล้ว

      content-x.php is there to display a list of category items, if a single-x.php is available then the full post will be displayed through that file. In this way a post can have a different layout, for example post tags not displayed in category list but only in full post. If only one single.php is available than all full posts will be displayed through that file. One the Wordpress website you can find an order of files WP looks for when displaying content.

  • @jcjohn3502
    @jcjohn3502 8 ปีที่แล้ว

    Hello sir, great tutorial!. I have a question.. what's the requirement of making a next/previous post link ?. I mean what if i only have index.php in my page ? It will auto generate a page?

    • @jcjohn3502
      @jcjohn3502 8 ปีที่แล้ว

      also sir additional question. What if i only want 6 post per page in a specific category only and let them do the next/previous post link to handle more than 7 post?

  • @policeuac
    @policeuac 7 ปีที่แล้ว

    Sorry for my endless questions because i'm working hard on that wordpress :) So my question is how to design custom loop category.php with pagination but i mean can we adjust how many posts on per category page?

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Yes, you can do all of this via the WP_Query.
      I don't specifically touch these examples in my videos, but you should take a look at this link to learn everything about the WP_Query() codex.wordpress.org/Class_Reference/WP_Query

  • @HamayunRazaFarooq
    @HamayunRazaFarooq 7 ปีที่แล้ว

    Aless, does the code for previous & next posts as:

    work in a php page other than index.php too??
    Because I have used the above code for my page named as: page-work.php(work is the slug of a page named as Work), but the older & newer posts links do not show-up with this code.

    • @HamayunRazaFarooq
      @HamayunRazaFarooq 7 ปีที่แล้ว

      and
      do work but next_posts_link(); and previous_posts_link(); do not show up the links..

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      There's a new and easier method implemented by WordPress, called the Post Pagination. Check it out: codex.wordpress.org/Function_Reference/the_posts_pagination

  • @MoxetKhan
    @MoxetKhan 9 ปีที่แล้ว +2

    Thank you so much, it resolved my issue. Subscribed :)

  • @christopherbiddle8522
    @christopherbiddle8522 4 ปีที่แล้ว

    Hey Alessandro,
    The explicit pagination doesn't seem to work when I try to see posts within a specific category. When I click on a category, the pagination works, but it is showing ALL the posts, not just the posts in the selected category. Now, if I comment out these three lines in your index.php:
    $currentPage = (get_query_var( 'paged' )) ? get_query_var( 'paged' ) : 1;
    $args = array( 'posts_per_page' => 3, 'paged' => $currentPage );
    query_posts( $args );
    then go into Settings and set the "Blog pages show at most" back to 3 from 10, then the category functionality is restored. Any idea how to get the category functionality to work with your added code?
    Also,thank you so much for these vids. You are an amazing person! Sent a small donation your way.
    -Chris

    • @christopherbiddle8522
      @christopherbiddle8522 4 ปีที่แล้ว

      I think I figured it out. Needed to add the 'cat' parameter to the array so the middle line reads:
      $args = array( 'posts_per_page' => 3, 'paged' => $currentPage, 'cat' => get_query_var( 'cat' ));
      -Chris

  • @kudafoolhu
    @kudafoolhu 9 ปีที่แล้ว

    Thank you Alex, when is the next video?

  • @oksanaromaniv7102
    @oksanaromaniv7102 8 ปีที่แล้ว

    Thank you for this video! I'm a complete beginner and your tutorial helps me to clear things a lot. Can you advise how to fix pagination in a custom loop if the next page link is redirecting to 404 page? I've been looking for all the google like 2 days now and I can't find the solution q-q

    • @HansKr
      @HansKr 8 ปีที่แล้ว +1

      Take a look at the WP codex for "next/previous_post_link", you can exlcude terms by ID

  • @parkashsaini868
    @parkashsaini868 9 ปีที่แล้ว

    very help ful tutorial sir. I liked it and share it on facebook and google plus.
    Sir I have a problem if u can help me. I created a sidebar(widget area) and add custom menu widget in this sidebar. Now how can i add bootstrap classes to this menu. please sir.

  • @helmutverschooren3029
    @helmutverschooren3029 6 ปีที่แล้ว

    Hi Allessandro! I am running into 404 errors with the pagination of custom queries. According to the internet this is a mayor bug in WP. Let's say you create 5 posts and set $args of the custom query to show 2 posts/page. The admin option 'Blog pages show at most' is set to 3. The pagination links are rendered correctly, but I can't open .../page/3/. I get a 404 error instead. The only reason I can think of is that the Admin option value of 3 is still used to generate the permalinks and therefore only creating the first page and .../page/2/, since 5 posts do in fact fit on 2 pages when you would set 3 posts/page. I have tried numerous combinations of settings and they all confirm that theory. I have encountered this problem only on archive pages and the index page so far. I have no troubles on static page templates. According to the tutorial you don't seem to have this problem. Thanks!

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      That shouldn't be a problem. The "Blog pages show at most" option doesn't create any permalink, and doesn't affect the number of pages available as permalinks.
      The /page/n/ URL is dynamically generated based on the amount of posts the post_loop() and WP_Query() can find in your page.
      Be sure your post loop is correctly handling the pagination and returning the properly counted posts.
      Check my source code on Github to double check if you have any typos.

    • @helmutverschooren3029
      @helmutverschooren3029 6 ปีที่แล้ว

      Double checked it and the behavior of the pagination errors DOES depend on the value in the admin panel, when working with custom queries or altering the main query. I had to use an action hook 'pre_get_posts' in functions.php to set the 'posts_per_page' for each individual template file. Two other questions though: 1. If I am on a static page, let's say .../contact/, I can access the same page via .../contact/page/999/ Is there a way to solve this? Maybe redirecting them to .../contact/ 2. When using a custom query on a static page, the page links take me al the way up the last page (for example .../page/3/) but when I manually type .../page/4/, I get the same page with a "No results" message (coded) instead of a 404 page. Can I alter this behavior? Thanks!

  • @r3flex824
    @r3flex824 7 ปีที่แล้ว +1

    Isnt it more practical to put the post's loop into a template so later on you can use get_template_part(); function?

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      Yes, absolutely!
      I explained the templates in future videos. This video is totally for beginners and with the main purpose of explaining all the features and options available for wordpress.
      Cheers

  • @muhammadsharshar6069
    @muhammadsharshar6069 7 ปีที่แล้ว

    Thank you :D
    Can I ask a question ! How can I use CSS with Wordpress ?

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      Hi, thanks for watching. Ehm, what do you mean how to use CSS with WP?
      In this series, I explain step by step how to do it at video 2. Did you watch the entire series or only this video?

    • @muhammadsharshar6069
      @muhammadsharshar6069 7 ปีที่แล้ว +1

      I am watching this AWESOME series from the first video
      I mean how I can change an element style as example: how i can change the style of navbar with css and how can I use classes or ID !?

  • @ultras6322
    @ultras6322 6 ปีที่แล้ว

    it is possible to make pagination numbers (paginate_links) inside single page with normal query loop??

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      To have a pagination bar with numbers, you can use the_post_pagination()
      developer.wordpress.org/reference/functions/the_posts_pagination/
      Not sure it'll work fine in the single.php file, but you should be able to make it work with a custom wp_query

  • @sarichchantree7481
    @sarichchantree7481 8 ปีที่แล้ว +1

    Hi again! It was so weird that I typed and quad-checked my index.php file and still not getting the pagination to work. But when I use your index.php instead, it just work of all the sudden. Their might be a tiny mistake that I overlooked with my file.
    Great job as always, sir! :D

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Sarich Chantree Happy you solved your problem! Cheers

  • @itzelbrachomolina3446
    @itzelbrachomolina3446 6 ปีที่แล้ว +1

    best wp tutorial ever!!

  • @aljosa212
    @aljosa212 6 ปีที่แล้ว

    The syntax for next and previous post is working on a index.php page but on a single.php page the same code is not working. what is the problem?

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      DId you check my source code on GitHub? Is the problem showing up with my code as well?

    • @aljosa212
      @aljosa212 6 ปีที่แล้ว

      Alessandro Castellani no i didnt i Will download your code and try

  • @nasrin9320
    @nasrin9320 4 ปีที่แล้ว +1

    Thank you, Alessandro,
    I just want to mention it, be careful for Pagination in single.php write previous_post_link, not previous_posts_link , because we wrote posts instead of post in index.php .
    my pagination in single.php didn't work and after long checking, I found my mistake :)

    • @lantoaphatphap-f9r
      @lantoaphatphap-f9r ปีที่แล้ว

      I have found out, the previous_posts_link is for multiple post and cause by it's query load all the post and sort all the latest post to present first then it need to be reversed. Actually, there are previous_posts_link and previous_post_link. The previous_posts_link for multiple posts load and the previous_post_link is for single post. The multiple posts load is not working with the WP_Query instance, it only working with query_posts and the default posts load function.

  • @johanstam3602
    @johanstam3602 8 ปีที่แล้ว

    Hi Alessandro, can I use the same structure for custom posts?

    • @johanstam3602
      @johanstam3602 8 ปีที่แล้ว

      I am using the Underscore theme and I see there is a function the_post_navigation(); in the index file. How can I work with that on having pagination on custom types?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      The post navigation should also work for custom post types. Did you try? Are you having some particular issue with it?

    • @johanstam3602
      @johanstam3602 8 ปีที่แล้ว

      I am no sure how to set it up on my custom-page. Can you give me a direction? I am using it on a volunteers site for disabled persons. I want to show 4 posts and show more posts on a new page. The WP-Query works fine, but can't figure out how to get the links to the other older posts.

  • @andoy_abarquez
    @andoy_abarquez 8 ปีที่แล้ว

    Hi Alessandro,
    Do you have a tutorial where i can also make a pagination for the list of blog loop post from wp_query result.?

  • @saini42787
    @saini42787 8 ปีที่แล้ว +1

    howdy Alessandro Castellani presenty i am able to convert a html code to wordpress but sometimes i have to add total html content rather calling it through wordpress functions and hooks . i would really love to see tutorials on converting html properly to wordpress with proper functionality from you..
    thanks
    rohit saini

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +saini42787 Kepp following the WP101 series, and after you're done, jump into the Premium Theme Dev series, and you will learn everything you need.

    • @saini42787
      @saini42787 8 ปีที่แล้ว

      ok sir thnx a ton

  • @evanyang000
    @evanyang000 6 ปีที่แล้ว

    I found two awesome plugins on a website, but after many times of attempt, I still can not find out the correct plugin-names, could you help to figure out? Thanks.

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      It should simply be the name of the folder.

    • @evanyang000
      @evanyang000 6 ปีที่แล้ว

      @@alecaddd thanks for your reply anyway

  • @policeuac
    @policeuac 7 ปีที่แล้ว

    I have a weird problem with that pagination links.
    1) when i type previous_posts_link and next_posts_link they have disappearing but when i type previous_post_link and next_post_link they have appearing lol :D (without "s" letter)
    2) its not clickable so its just text when i type just like you (next_post_link('

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      Are you trying to use these methods inside a static page? Those methods work only on the index page.
      Try to use also the_posts_pagination() and see if it prints something.

    • @policeuac
      @policeuac 7 ปีที่แล้ว

      Alessandro Castellani I finally understand and did it :D

  • @Xasta11
    @Xasta11 8 ปีที่แล้ว +1

    I didn't understand the part :
    $currentPage = (get_query_var('paged')) ? get_query_var('paged') : 1;
    why "paged" is the first?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +1

      This is an inline IF statement to assign a value to the variable $currentPage.
      Basically I'm checking if the user is watching a page different than PAGE 1 from the list of blog posts, if get_query_var('paged') is true ? I assign the current page number to the variable, otherwise I assign 1.

  • @EmmyMabs
    @EmmyMabs 8 ปีที่แล้ว

    this does not work for newspro theme by studiopress. please can you suggest me a plugin or how i can add paginaion for newspro theme?

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      +Emmy Mabs Hi, I never used Newspro theme. The pagination functions are default built-in of WordPress, they should work on every theme. I suggest you to try to contact the maker of the theme and ask for help.
      Cheers

  • @allenliu1672
    @allenliu1672 9 ปีที่แล้ว +2

    how did u type the "arrow" symbol

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว +2

      +Allen Liu It's an HTML entity: www.w3schools.com/charsets/ref_html_entities_4.asp

    • @spradohak
      @spradohak 8 ปีที่แล้ว +2

      +Allen Liu if you are on mac for the left arrows hold ( alt and backslash ) it's in the top of return key,
      for the right arrows hold ( shift + alt and backslash ).

  • @سيفالدليمي-ز8ق
    @سيفالدليمي-ز8ق 8 ปีที่แล้ว +1

    Thank you Thank you Thank you Thank you Thank you

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว +3

      You're very very very very welcome

  • @iamnidal
    @iamnidal 6 ปีที่แล้ว +1

    if your next_posts_link() isn't showing you need to pass it's name and *your-query*->max_num_pages .... for example next_posts_link("Older Posts", $posts_query->max_num_pages)

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Thanks for the heads up

  • @KhairulRodrokhairulsilencer
    @KhairulRodrokhairulsilencer 7 ปีที่แล้ว +1

    Thanks brother. its very important

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว +1

      You're very welcome :D

  • @assstudio1760
    @assstudio1760 8 ปีที่แล้ว +1

    you are awesome thank you i hope you be great developer more and more thanks

    • @alecaddd
      @alecaddd  8 ปีที่แล้ว

      Thank you so much

  • @chengchivasentertainment4966
    @chengchivasentertainment4966 7 ปีที่แล้ว

    how make pagination number 1-2-3 ...7-8-9 admin?
    thanks you

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      You can use the_post_pagination() method
      codex.wordpress.org/Function_Reference/the_posts_pagination

    • @chengchivasentertainment4966
      @chengchivasentertainment4966 7 ปีที่แล้ว

      thanks admin, but not custom code html panigation

  • @TheNeelthakur
    @TheNeelthakur 7 ปีที่แล้ว

    thank u so much 4 all videos ...
    and I have one query, I want to use offset in query_post with loop and pagination but it didn't work plz help me.
    Code:-
    $cp = (get_query_var('paged')) ? get_query_var('paged'): 1;
    $args=array('post_per_page'=>3,'paged'=>$cp, 'offset' => 6)
    query_posts($args);
    then same like ur tutorial

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      You have a typo in your args variable. It's posts_per_page, not post_per_page.
      Cheers

  • @1986nesha
    @1986nesha 7 ปีที่แล้ว

    Hey man, again great lessons! But i am having a problem with pagination. I made a custom post template page that should display all posts of selected category, and when i add the pagination code below and inspect the element, the div is completely empty, it is not showing anything. I tried various examples that i found in Codex, but it will not work. I have 12 posts with that category and I've set that it only shows 4, and it does show 4 but the pagination is just not visible. Do i need to name the template in a specific way? So far i named it page-news-template.pxp. Also, do i need to set it as a post page in Settings->Reading?
    Here is the code below:
    content

    • @1986nesha
      @1986nesha 7 ปีที่แล้ว

      Ok, apparently i need glasses, i wrote next_posts instead of next_post, so sorry man :) 3 hours well spent...

    • @1986nesha
      @1986nesha 7 ปีที่แล้ว +1

      Hm, ok so one more correction, it seems that next_post_link works, but next_posts_link does not. It will not take me to another page, it only works if i make a link to the post directly.. I am lost.. Do i need to make another page?

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      This method is a bit old, even it should still work without problem, you can always try a newer method called the_posts_pagination()
      Check this page: developer.wordpress.org/reference/functions/the_posts_pagination/

  • @ernestogarcia1573
    @ernestogarcia1573 9 ปีที่แล้ว +4

    Thank you Aless

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      Ernesto García Thank you!

  • @wasi-wasif9663
    @wasi-wasif9663 6 ปีที่แล้ว

    Sir, could you please give the numbers pagination of post tutorial.

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Mh, I'm not sure I understood your question.
      If you want to have a numbered pagination, you can use the the_post_pagination() method of WordPress. If your question was something else, I'm sorry I didn't get it 😅

    • @wasi-wasif9663
      @wasi-wasif9663 6 ปีที่แล้ว

      @@alecaddd Sorry to confuse you and you have correctly understood my question. And i will try this method "the_post_pagination()" to make the numbered pagination of post. Thank you so much.

    • @wasi-wasif9663
      @wasi-wasif9663 6 ปีที่แล้ว

      @@alecaddd Sorry to confuse you. You have understood my question and I will try this method " the_post_pagination() " to make the numbered pagination of post. Thank you so much.

  • @yiyudexiaojiejie
    @yiyudexiaojiejie 3 ปีที่แล้ว

    thank you, that's amazing

  • @ck0024
    @ck0024 5 ปีที่แล้ว +1

    *Super Simple*

  • @arsalarsi7858
    @arsalarsi7858 2 ปีที่แล้ว

    my blog post navigation code is not working I am using the page template "page-blog.php" I am getting null when I var_dump next_posts_link()

  • @dhrubodhrubo6262
    @dhrubodhrubo6262 7 ปีที่แล้ว +1

    Great tut.....

  • @arsalarsi7858
    @arsalarsi7858 2 ปีที่แล้ว

    my single.php pagination is working fine
    but not blog

  • @manualvarado2212
    @manualvarado2212 6 ปีที่แล้ว +1

    For some reason, directly using the value returned by get_query_var( 'paged' ) is not breaking my loop.
    But anyway, checking the good 'ol codex, get_query_var accepts a second optional argument for a default value, so pretty neatly we can use: get_query_var( 'paged', 1 );
    😻💓

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Good call, always check the documentation and never blindly trust an online tutorial 😄

    • @manualvarado2212
      @manualvarado2212 6 ปีที่แล้ว

      @@alecaddd Your videos are truthful enough anyway!

  • @MrArehammar
    @MrArehammar 9 ปีที่แล้ว +1

    Thanks again,
    I noticed this in your awesome.css:
    /*
    .second-row-padding:nth-child(2) { padding-right: 0; }
    .second-row-padding:nth-child(3) { padding-left: 0; }
    .third-row-padding { padding: 0; }
    .third-row-padding:nth-child(4) { padding-left: 15px; }
    .third-row-padding:last-child { padding-right: 15px; }
    */
    .no-margin { margin: 0; }
    .blog-item { padding: 0; }
    When did you change this?
    Also:
    The row padding did not work so good for me, I had to do this:
    .third-row-padding { padding: 0px }
    .third-row-padding:nth-child(4) { padding-left: 15px; }
    .third-row-padding:nth-child(6) { padding-right: 15px; }
    strange:)

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      I changed the html markup and CSS to avoid that spaghetti code in the CSS.
      I'm impressed you noticed that because I actually changed it quickly before a session, and I didn't do a tutorial about it.
      Try to check the differences between our code to solve your row issue.
      Great work!

    • @MrArehammar
      @MrArehammar 9 ปีที่แล้ว +1

      Alessandro Castellani
      Thanks, I will! :)
      BTW! Any plan for 101 nr 14? (when?)
      Subscribed and waiting:)

    • @alecaddd
      @alecaddd  9 ปีที่แล้ว

      Oscar Arehammar usually I record a new tutorial every Sunday and I publish it on Monday or Tuesday, I know I'm a bit sloppy and should follow a more strict publishing timeline.

  • @stpengineering
    @stpengineering 6 ปีที่แล้ว +1

    Big,
    i have a question.
    Questa è la paginazione realizzata come da questo video tutorial, funziona correttamente, ma...
    codepen.io/Alighieri/pen/RJXVym
    Ho notato una cosa. Se imposto il numero di articoli nel backend a 10 post per pagina, ed io ho 8 articoli pubblicati, apro la pagina blog e visualizzo 3 post come da query, ma, quando clicco su "older post" mi esce la pagina di errore 404. In pratica la pagina non esiste. In teoria è corretto che non esista perchè avendo 8 articoli pubblicati e impostati 10 per pagina nelle impostazioni. Come si può risolvere? E' normale che sia cosi? Spero tu mi abbia capito :D

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Mhh, no, non dovrebbe andare ad una pagina 404. Non ricordo se ho settato la pagination già da questo tutorial o in video futuri, ma se usi una custom wp query, devi adattarla per accettare la richiesta di pagination.

    • @assuntapiscitelli7178
      @assuntapiscitelli7178 6 ปีที่แล้ว

      Alessandro Castellani molto strano devo studiarla. Se ho 8 articoli pubblicati devo impostare 7 per page nel backend. Una unità in meno rispetto ai post pubblicati per farla funzionare ... gulp

  • @Snaketazzie
    @Snaketazzie 8 ปีที่แล้ว

    my pagination doesnt click

    • @raulterraferrao696
      @raulterraferrao696 8 ปีที่แล้ว

      This is because you mistype the 'next_posts_link' or' previous_posts_link' as 'next_post_link' or 'previous_post_link'.

  • @zafershoaybi
    @zafershoaybi ปีที่แล้ว

    nice❤

  • @stpengineering
    @stpengineering 6 ปีที่แล้ว

    Big,
    come si può fermare il numero di articoli? Se ce ne sono altri vengono aggiunti di continuo in una nuova col-4
    s22.postimg.cc/9tnybme7l/col-4.gif
    Questo approccio non funziona :D
    s22.postimg.cc/4wadqc4gx/col-dollar.gif

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Puoi gestire il numero di posts per page via WP_Query. Se non ricordo male, dovrebbe esserci un video nella serie dove spiego come fare.

    • @stpengineering
      @stpengineering 6 ปีที่แล้ว +1

      Sono uno studente modello ... ho studiato ahaha
      s33.postimg.cc/io4r2z7cv/Cattura.gif
      Look at thattt! Thank You

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว

      Grande! Fai attention però, non dovresti mai mettere una custom WP_Query all'interno di un have_posts() if statement. Dovresti testare se hai posts solo dopo aver settato una nuova WP_Query()

    • @stpengineering
      @stpengineering 6 ปีที่แล้ว

      Faccio cosi?
      s22.postimg.cc/vu66l6xdt/all.gif
      Oppure questa con un "php" in meno?
      s22.postimg.cc/3jz5verv5/all2.gif
      simply way - lol

    • @alecaddd
      @alecaddd  6 ปีที่แล้ว +1

      Fai attenzione alla prima condition. Anche in quella dovresti usare la tua custom query:
      if ($sixarticle->have_posts()): $i = 0;

  • @holalabellebille
    @holalabellebille 7 ปีที่แล้ว +1

    i forgot "Paged" in the array of arguments
    Sorry forget my previous comment !

    • @alecaddd
      @alecaddd  7 ปีที่แล้ว

      I'm glad you were able to solve it
      Happy Coding!