- This topic has 19 replies, 4 voices, and was last updated 4 years ago by Tom.
-
AuthorPosts
-
April 13, 2018 at 9:43 am #549627Justin
Hello! How would I go about adding the pagination at the top of the page to advance to additional pages on archive pages? As it stands, this feature is at the bottom but we’d like to a) Add it to the top, and b) change the styling to numbers in boxes. Are these tasks feasible? Thanks!!
April 13, 2018 at 12:10 pm #549742LeoStaffCustomer SupportHi there,
At the very top of the page?
If so try this snippet:
add_action( 'generate_before_header', 'lh_move_pagination' ); function lh_move_pagination() { if ( is_archive() ) { the_posts_pagination( array( 'end_size' => 2, 'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ), 'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ), 'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ), ) ); } }
Adding PHP: https://docs.generatepress.com/article/adding-php/
April 15, 2018 at 12:54 pm #551091JustinHmm, that’s close to what I need but instead of the very top of the page, I need it in the top of the section – similar to how this support forum has pagination at top and bottom of the forums section. How would I accomplish this for archived post pages?
April 15, 2018 at 4:43 pm #551210LeoStaffCustomer SupportHmm try the inside content container:
add_action( 'generate_inside_container', 'lh_move_pagination' ); function lh_move_pagination() { if ( is_archive() ) { the_posts_pagination( array( 'end_size' => 2, 'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ), 'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ), 'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ), ) ); } }
April 18, 2018 at 2:17 pm #554135JustinThanks, that’s better. However, it’s in the upper left. How can I go about adjusting where it lives (i.e. upper right and not so far up?
April 18, 2018 at 8:36 pm #554287LeoStaffCustomer SupportActually can you try a different hook? I think it will work better.
add_action( 'generate_before_main_content', 'lh_move_pagination' ); function lh_move_pagination() { if ( is_archive() ) { the_posts_pagination( array( 'end_size' => 2, 'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ), 'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ), 'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ), ) ); } }
Let me know π
April 22, 2018 at 8:52 pm #557584JustinThat didn’t seem to make any difference. I appreciate the help, but do you have any other suggestions? I am looking to place the pagination at the top – very similar to pagination on these forums!
April 22, 2018 at 9:29 pm #557606LeoStaffCustomer SupportHmm I tested the code and it should show up similar to this site.
Can you add the code in so I can see where it’s showing up for you?
April 23, 2018 at 10:12 am #558224JustinSure! I’ve added it back. You’ll see on our /News page that the pagination is at the top, in the upper left of the container. It doesn’t look like the pagination on these forums. We also want to align it to the right of the content container (and to the left of the sidebar). Thanks in advance!
April 23, 2018 at 6:47 pm #558562TomLead DeveloperLead DeveloperSorry we didn’t get back to you quicker – looks like you removed it again.
Any chance you can show me a screenshot of what it looks like when you use Leo’s code?
April 23, 2018 at 7:36 pm #558580JustinNo worries! It’s actually still there.
April 23, 2018 at 11:03 pm #558634TomLead DeveloperLead DeveloperAh, missed it somehow!
Try this code instead:
add_action( 'generate_before_main_content', 'lh_move_pagination', 0 ); function lh_move_pagination() { if ( is_archive() ) { the_posts_pagination( array( 'end_size' => 2, 'mid_size' => apply_filters( 'generate_pagination_mid_size', 1 ), 'prev_text' => apply_filters( 'generate_previous_link_text', __( '← Previous', 'generatepress' ) ), 'next_text' => apply_filters( 'generate_next_link_text', __( 'Next →', 'generatepress' ) ), ) ); } }
Let me know π
April 24, 2018 at 7:41 am #559029JustinIt’s still in the same place π
April 24, 2018 at 9:40 am #559262TomLead DeveloperLead DeveloperThe HTML is actually in the correct place now.
Now it just needs a little CSS:
.site-main > .nav-links { padding: 40px 40px 0; }
April 24, 2018 at 10:05 am #559291JustinThat worked! Perfect, thanks so much!!
-
AuthorPosts
- You must be logged in to reply to this topic.