- This topic has 17 replies, 3 voices, and was last updated 7 years, 5 months ago by
Tom.
-
AuthorPosts
-
December 5, 2016 at 1:31 pm #251711
Bobby
Hello Tom,
I was searching the forum to see if I could find any info on how to style the pagination links, but i did not see anything in particular.
In my blog post, I like to use the wordpress “<!–nextpage–>” syntax to break up very long pages. As you know, when that syntax is used, it generates pagination links to the next pages.
I’m trying to style my single post pagination links to look like the example in the screen shot below. I want the pagination links to have the previous and next page links added along with the square border boxes around each page number link.
See screenshot below:http://playerwags.com/wp-content/uploads/2016/12/pagination-example.png
Is there some quick simple php code I can add to the php functions file to get this look, or is this a more detailed coding project?
Thanks.
December 5, 2016 at 8:18 pm #251759Tom
Lead DeveloperLead DeveloperHi there,
The default WordPress HTML markup isn’t great, so there’s not tons to work with.
This might be a good start:
.page-links a { display: inline-block; border: 1px solid #DDD; padding: 5px 10px; line-height: 1; margin-right: 10px; } .page-links a:hover { background:#222; color: #FFF; border-color: #222; }It would be nice to removes the “Pages” text and have HTML wrapped around the currently selected page link so we could style them, but it doesn’t look like the function allows this.
I’ll look into it to see if there’s anything I can do in the parent theme 🙂
December 6, 2016 at 10:56 am #252014Bobby
OK, thank you Tom. The CSS works for the box and borders.
December 6, 2016 at 11:09 am #252023Tom
Lead DeveloperLead DeveloperYou’re welcome 🙂
November 2, 2018 at 2:19 pm #717598Frans
Thanks ! This works for me as well.
I tried to do the same with category pages and navigators, This works:
.page-numbers { display: inline-block; background-color: #628907; padding: 5px 10px 5px 10px; color: #fff; }This also
.page-numbers.current { background-color: #fff; padding: 5px 10px 5px 10px; color: #628907; }But this doesn’t:
.page-numbers a:hover { display: inline-block; background-color: #90CB0D; padding: 5px 10px 5px 10px; color: #fff; }And this doesn’t work either:
next.page-numbers a:hover { background-color: #90CB0D; padding: 5px 10px 5px 10px; color: #fff; }How can I define an a:hover style ?
Thanks !
Frans
November 2, 2018 at 3:53 pm #717658Tom
Lead DeveloperLead DeveloperHi there,
Can you link me to a page with one of those elements so I can see why it’s not working?
November 3, 2018 at 4:08 am #717887Frans
Thanks !
This is a (single) post, where .page-links (and page-links a:hover) work correctly (color change on mouse over):
https://medische-ethiek.nl/voltooid-leven-2/
I tried to do the same styling on category pages. This is a category overview where .page-numbers work, but the a:hover doesn’t:
https://medische-ethiek.nl/category/actueel/
Frans
November 3, 2018 at 9:25 am #718112Tom
Lead DeveloperLead DeveloperSomething like this should work:
.nav-links a:hover, .nav-links a:focus { background: #fff; color: #222; }November 3, 2018 at 11:58 am #718189Frans
Thanks ! .nav-links a:hover is the solution. Unfortunately, .nav-links a:focus did not work. I used a combination of .nav-links and .page-numbers:
.page-numbers { display: inline-block; background-color: #628907; padding: 5px 10px 5px 10px; color: #fff; } .nav-links a { color: #fff; } .page-numbers.current { background-color: #fff; padding: 5px 10px 5px 10px; color: #628907; } .nav-links { text-align: right; } .nav-links a:hover { background-color: #90CB0D; padding: 5px 10px 5px 10px; color: #fff; }Thanks !
Frans
November 3, 2018 at 5:47 pm #718338Tom
Lead DeveloperLead DeveloperGlad you got it working! Thanks for sharing your code 🙂
November 7, 2018 at 3:03 am #721056Frans
Today I saw that there is a situation in which these solutions don’t work: the navigation within WP pages. The above mentioned solutions address navigation in posts, categories and archives, but not pages. Especially, the a:hover does not work. Both .page-numbers a: hover {} and .nav-links a:hover {} do not have effect in this situation. What class should be used for the a:hover in page navigation ? If I inspect the page with Chrome, I can only find the page-numbers class.
E.g (bottom): https://medische-ethiek.nl/publicaties-katholieke-stichting-medische-ethiek/
Thanks !
Frans
November 7, 2018 at 8:34 am #721407Tom
Lead DeveloperLead DeveloperThose links need this CSS:
.page-numbers:not(.current):hover { background: #222; color: #fff; }November 7, 2018 at 8:52 am #721417Frans
Thanks! The class is correct, but how do I add the a:hover. Adding after not(.current) with or without colon does not work.
Frans
November 7, 2018 at 3:44 pm #721670Tom
Lead DeveloperLead Developer.page-numbersis the class of the<a>element, so there’s no need to adda:hoverafter it.November 8, 2018 at 1:24 am #721869Frans
Sorry, I did not explain my problem clearly.
This works, but it is applied permanently (on pages):
.page-numbers:not(.current) { background: #222; color: #fff; }However, I want to have this effect only on mouse over on links. I tried:
.page-numbers:not(.current) a:hover { background: #222; color: #fff; }.page-numbers a:not(.current):hover { background: #222; color: #fff; }.page-numbers a:hover:not(.current) { background: #222; color: #fff; }Those three stylings do not do anything, also the permanent effect of the previous solution has disappeared.
So, how can I get in the a:hover together with the :not(.current) ?
Frans
-
AuthorPosts
- You must be logged in to reply to this topic.