Help editing a few things
-
Sorry for the wacky URL, I’m building this module on a non-front-facing page so users can’t see it.
Due to accessibility reasons, blog modules should have “read more” text under the copy for screen readers. Is there a way to add “read more” underneath each copy?
(For styling – see the Read More text on the front page https://517mag.com/)
Also – how do I change the different sizes of the different copy?
I’d like to add a few more pixels of padding below the category taxonomy, increase the line height of the title a little bit so there’s more space between the lines of the title when it wraps, and increase the size of the body copy a little bit. In addition to having that read more text.
I notice when I do custom CSS targeting “body” it actually targets all the text including the taxonomy and the title.
-
This topic was modified 10 months ago by
nicholasm3.
The page I need help with: [log in to see the link]
-
This topic was modified 10 months ago by
-
Hi @nicholasm3,
Regarding your first question, to add a Read More button to your popular posts you could for example take advantage of the HTML customization options provided by WordPress Popular Posts.
To be more precise, since you’re using the Cards theme with your popular posts list try adding your “Read More” link to the Post HTML Markup field like so:

<li class="{current_class}">{thumb_img} <div class="wpp-item-data"><div class="taxonomies">{taxonomy}</div>{title} <p class="wpp-excerpt">{excerpt}</p><a href="{url}" class="more-link">Read More</a></div></li>As for your second question, to edit the styling of the Cards theme you have a couple of options:
- You can override the Cards theme styles (or any theme style) by copying the theme files into your WordPress theme and change it from there.
- You can inject your own CSS rules via filter hook.
For example, let’s say you decided to go for the filter hook option. You’ll want to add something like this to your theme’s functions.php file (or via the Code Snippets plugin):
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.8em; }
.wpp-cards li .more-link { color: #0047BB; font-size: 17px; text-decoration: underline; }
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);Of course, feel free to adjust where/if needed.
If you have any further questions please let me know.
Thank you Hector! It’s so awesome how active you are to help people on here.
It’s so close with your help, just a couple more fixes.
I tried editing your code to add color to the taxonomies (same as the read more link, #0047BB) but it’s not taking. I tried using !important tag as well to no avail. Here’s the code I have right now in Code Snippets
/**
- Adds custom styling rules for the ‘Cards’ theme.
* - @param string $additional_styles
- @param string $theme_name
- @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( ‘cards’ == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { color: #0047BB; margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { color: #0047BB; font-size: 17px; text-decoration: underline; }
EOD;
}
return $additional_styles;
}
add_filter(‘wpp_additional_theme_styles’, ‘wpp_additional_css_rules’, 10, 2);
Last thing – is there a way to force line break before the Read More so that it’s below the content on a new line and not immediately following it?
Thanks again for all your help!
Edit: Sorry, 1 more. I have author and date checked to display in Appearance > Widgets customization options but they aren’t showing up?

-
This reply was modified 10 months ago by
nicholasm3.
Thank you Hector! It’s so awesome how active you are to help people on here.
Well, someone’s gotta do it and that someone happens to be me 😛
Don’t mention it, glad I can help!
I tried editing your code to add color to the taxonomies (same as the read more link, #0047BB) but it’s not taking. I tried using !important tag as well to no avail.
That’s because you’re targeting the .taxonomies DIV tag. To style the actual taxonomy link (A tag) inside that .taxonomies DIV you’ll want to target it like this (yeah, CSS can be funny like that):
.wpp-cards li .taxonomies a { color: #0047BB; }Or if you don’t want to be that specific you could just target all A tags like so:
.wpp-cards li a { color: #0047BB; }and then your .more-link can be rewritten like this since it’ll inherit the color attribute from the rule above:
.wpp-cards li .more-link { font-size: 17px; text-decoration: underline; }is there a way to force line break before the Read More so that it’s below the content on a new line and not immediately following it?
Yep, you make the .more-link element a block element via the display property, like so:
.wpp-cards li .more-link { display: block; font-size: 17px; text-decoration: underline; }I have author and date checked to display in Appearance > Widgets customization options but they aren’t showing up?
That’s expected. If you take a closer look at the HTML structure of the Cards theme you’ll notice that none of these elements are present.

Hence, no author and no publish date.
Fortunately, you can add them. WordPress Popular Posts has these things called Content Tags that are basically placeholders that will be replaced with, well, content (hence the super creative name Content Tags haha) once the list is rendered on screen.
Since I’m more of a show-don’t-tell kind of guy, let’s say for example that you wanted to add the author name next to the post title (Some Title by Author). You would then use the {author} content tag to render it right where you want, eg:
<li class="{current_class}">{thumb_img} <div class="wpp-item-data"><div class="taxonomies">{taxonomy}</div>{title} by {author} <p class="wpp-excerpt">{excerpt}</p><a href="{url}" class="more-link">Read More</a></div></li>Same principle applies to the date, only difference is that you’d use the {date} content tag. For example:
<li class="{current_class}">{thumb_img} <div class="wpp-item-data"><div class="taxonomies">{taxonomy}</div>{title} by {author} on {date} <p class="wpp-excerpt">{excerpt}</p><a href="{url}" class="more-link">Read More</a></div></li>You can of course modify the HTML structure to whatever feels best.
I don’t want to target all a tags, so I tried inserting
.wpp-cards li .taxonomies a { color: #0047BB; }But it errored out the line 15 (EOD;) Said the indent was incorrect? I don’t know much about html hence all the help I need lol.
This is what I have
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; color: #0047BB; font-size: 17px; text-decoration: underline; margin-top: 15px; }
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);And I tried to add in the line like so:
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .taxonomies a { color: #0047BB; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; color: #0047BB; font-size: 17px; text-decoration: underline; margin-top: 15px; }
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);But I get this error

I tried hitting tab a few times to try and dumb troubleshoot it but no avail. The error would go away, but then the styles wouldn’t be appearing when I refreshed the page.
-
This reply was modified 10 months ago by
nicholasm3.
Hey @nicholasm3,
Yes, the indentation was indeed incorrect.

Welcome to the programming world where small things like that can easily trip you up haha.
Just make sure that the closing EOD; is at the same level spacing wise as $additional_styles, otherwise that will happen (the code below is using the right indentation and contains your changes too).
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .taxonomies a { color: #0047BB; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; margin-top: 15px; color: #0047BB; font-size: 17px; text-decoration: underline; }
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);Thank you for all your help!
@hcabrera nvm, one more question.
Upon QA testing I noticed that the card format does not translate well to mobile. Can you advise any solution for that?
It’s currently live on the frontpage at https://517mag.com
I would love if the text would collapse to be below the image once it hits mobile view but not sure how to implement that html.
-
This reply was modified 10 months ago by
nicholasm3.
Ah, it’s because you changed the dimensions of the thumbnail hahaha. That’s an oversight on my part.
The original theme was designed (by yours truly) with a small, square shaped post thumbnail. This is how the theme looks on mobile with that design in mind. It never occurred to me until this very moment that people would try using a larger image size…

So, one solution would be that on mobile have the thumbnail use the entire width of the screen and push all of the other elements down.

To do that, we’ll use something called media queries.
Give this a try:
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .taxonomies a { color: #0047BB; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; margin-top: 15px; color: #0047BB; font-size: 17px; text-decoration: underline; }
/** For screen sizes lower than 985px let's behave as a block element instead */
@media (max-width: 984px) {
.wpp-cards li { display: block; }
.wpp-cards li .wpp-thumbnail { display: block; width: 100%; max-width: 100%; height: auto; margin: 0; }
}
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);Thank you Hector! I made the images bigger because I want to show off the photography! (I am also the photographer lol) 😀
We’re so close! I’m once again having issues with this “indent” rule? I noticed with your code the category is right up against the photo when it goes to mobile mode. I figured okay, easy enough, just add a margin-top to taxonomies when it’s using the media card styling.
But when I add it to the section, I once again get that error from earlier about expecting a different indent.
This is what I’m trying to use:
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .taxonomies a { color: #0047BB; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; margin-top: 15px; color: #0047BB; font-size: 17px; text-decoration: underline; }
/** For screen sizes lower than 985px let's behave as a block element instead */
@media (max-width: 984px) {
.wpp-cards li { display: block; }
.wpp-cards li .taxonomies { margin-top: 15px; }
.wpp-cards li .wpp-thumbnail { display: block; width: 100%; max-width: 100%; height: auto; margin: 0; }
}
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);But I still get the error even though they’re lined up like you told me to 🙁

Thanks again for all your help
-
This reply was modified 10 months ago by
nicholasm3.
Ah, this time it’s because when you added that new .taxonomies rule you used the Tab key to add spaces while the rest of the code is using spaces. So you have 8 spaces everywhere vs 4 tabs on that line and so Code Snippet sees that as something not using the same indenting 😛
(This is one of the infamous conflicts among programmers: people who prefer spaces vs those who prefer tabs, the creators of Code Snippets are I suppose on the Tabs team haha).
Here, I replaced your tabs with 8 spaces and all is good:
/**
* Adds custom styling rules for the 'Cards' theme.
*
* @param string $additional_styles
* @param string $theme_name
* @return string
*/
function wpp_additional_css_rules($additional_styles, $theme_name) {
if ( 'cards' == $theme_name ) {
$additional_styles .= <<<EOD
.wpp-cards li .taxonomies { margin-bottom: 15px; font-size: 16px; }
.wpp-cards li .taxonomies a { color: #0047BB; }
.wpp-cards li .wpp-post-title { line-height: 1.5; }
.wpp-cards li .wpp-excerpt { font-size: 17px; line-height: 1.7em; }
.wpp-cards li .more-link { display: block; margin-top: 15px; color: #0047BB; font-size: 17px; text-decoration: underline; }
/** For screen sizes lower than 985px let's behave as a block element instead */
@media (max-width: 984px) {
.wpp-cards li { display: block; }
.wpp-cards li .taxonomies { margin-top: 15px; }
.wpp-cards li .wpp-thumbnail { display: block; width: 100%; max-width: 100%; height: auto; margin: 0; }
}
EOD;
}
return $additional_styles;
}
add_filter('wpp_additional_theme_styles', 'wpp_additional_css_rules', 10, 2);That is hilariously and ridiculously pedantic, tell them they’re a buncha nerds for me (I can say that cuz I am also a nerd).
The topic ‘Help editing a few things’ is closed to new replies.