Tagged: x
-
AuthorPosts
-
June 1, 2016 at 8:44 am #1020022
helloengParticipantHi, I found these 2 suggestions about how to mark new blog posts. Is this something that can be done with X-theme?
https://wordpress.org/support/topic/highlight-new-posts-1?replies=4
https://wordpress.org/support/topic/mark-new-posts-as-new?replies=4
Can you please take a look?
Thank you.
June 1, 2016 at 9:10 am #1020058
ThaiModeratorHi There,
Please add the following CSS under functions.php file locates in child theme:
add_filter( 'post_class', 'x_post_class' ); function x_post_class( $classes ){ if( the_date('U', '', '', FALSE) >= (time() - (7 * 24 * 60 * 60)) ){ $classes[] = "new-post"; } return $classes; }After that you can add new custom CSS with this CSS class:
.new-post { }Hope it helps 🙂
June 2, 2016 at 1:38 am #1021586
helloengParticipantHi thanks for answering.
I tried it but it didn’t work. Here is what I used:
-
X-child theme functions.php
add_filter( ‘post_class’, ‘x_post_class’ );
function x_post_class( $classes ){
if( the_date(‘U’, ”, ”, FALSE) >= (time() – (7 * 24 * 60 * 60)) ){
$classes[] = “new-post”;
}
return $classes;
}-
x-child theme style.css
.new-post {
background: #feffdd;
padding: 3px;
border: 1px solid #eeefd2;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
margin-left:5px;
font-size: small;
font-weight: bold;
}Technically, it should look like the attached screenshot.
Any ideas why it didn’t work? do you see any errors in my code?
June 2, 2016 at 5:48 am #1021879
Paul RModeratorHi,
To further assist you with this issue, we’ll first need you to provide us with your URL. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
June 3, 2016 at 6:56 am #1024040
helloengParticipantThis reply has been marked as private.June 3, 2016 at 7:09 am #1024048
helloengParticipantHello again
I don’t know why, but NOW it seems to work 😉
see attached screenshot.
Can you confirm? Do you see the color border around the June 3 post?
Thanks.
June 3, 2016 at 7:20 am #1024059
helloengParticipantHowever, I believe the above css should have resulted in the “NEW” sticker after the post title, as can be seen in the attached picture 😉
Any ideas why it has a different effect on my site?
June 3, 2016 at 7:26 am #1024062
helloengParticipantI took the css from this link:
http://www.wpbeginner.com/wp-themes/how-to-highlight-new-posts-for-returning-visitors-in-wordpress/
June 3, 2016 at 1:10 pm #1024555
JadeModeratorHi there,
Yes, I am seeing the highlight for the recent post. It seems to be working fine because the CSS you have added will only add a border and a highlight color for the post area.
June 4, 2016 at 2:54 am #1025388
helloengParticipantok, thank you 😉
June 4, 2016 at 8:34 am #1025622
ThaiModeratorYou’re most welcome 🙂
If you need anything else please let us know.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1020022 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
