-
AuthorPosts
-
February 26, 2019 at 2:07 am #1071584
Hi there,
This is regarding old post which is now closed https://kriesi.at/support/topic/enfold-enable-previous-and-next-post-navigation/ as I do not know if it is possible to re open it.
Mike already had assisted and helped me to show the arrows just for 1 category, as I was hiding them as default. What I want now to do is to add another category and if it works maybe another 2. I am not very familiar with the code and tried to modify it to my new needs.
I will post more information in the private area with a temporary login.Thank you,
VasilisMarch 2, 2019 at 7:10 am #1073533Hey Vasilis,
Sorry for the late reply, I changed your function so that it will add a class to two category types:add_filter( 'body_class', 'add_category_class' ); function add_category_class( $classes ) { if( is_single() && has_category('Τελευταία νέα') ) $classes[] = 'news-cat'; if( is_single() && has_category('Συγγραφείς') ) $classes[] = 'writers-cat'; return $classes; }
But because you want to hide the post nav on all pages except the ones with the classes I had to write another function to add the css. The original css is limited for “if” & “else” statements, where this javascript can handle it better. This means that you can remove the css used before from your Quick CSS, I have disabled it for now, so this function will work.
function hide_post_nav_css(){ ?> <script> (function($) { $(document).ready(function(){ if ($("body").hasClass("news-cat")) { $('.avia-post-nav').css({ 'display': 'block' }); } else if ($("body").hasClass("writers-cat")) { $('.avia-post-nav').css({ 'display': 'block'}); } else { $('.avia-post-nav').css({ 'display': 'none'}); } }); })(jQuery); </script> <?php } add_action('wp_footer', 'hide_post_nav_css');
Please be sure to clear your browser cache, and check your posts, also remember that the “post nav” will only show if the category has more posts to show, and the classes above are present.
Best regards,
MikeMarch 3, 2019 at 4:17 am #1073805Thank you very much Mike,
I added another category and it looks it works fineMarch 3, 2019 at 6:01 pm #1073980Hi,
I took another look and found that I made an error with tring to use “else if” & “else” and the same time, I have now corrected it.
You should know that the css in the Quick CSS is not in use now, I have removed it so it won’t be confusing.
In your css function code you were missing a closing bracket, I added it for you, now you can see what code to copy if you want to do it again.
The function for adding a class was correct
Unless there is anything else we can assist with on this issue, shall we close this then?Best regards,
MikeMarch 4, 2019 at 2:02 pm #1074361Hi Mike,
I just had a look and it does not seem to be working one category. https://aimonas.gr/%CE%B5%CE%BC%CE%BC%CE%B1%CE%BD%CE%BF%CF%85%CE%AE%CE%BB-%CE%B1%CE%BD%CE%B4-%CE%BA%CE%BF%CE%BD%CF%84%CE%BF%CE%B3%CE%B9%CE%AC%CE%BD%CE%BD%CE%B7%CF%82/
Posting details in private area.Thank you!
March 4, 2019 at 2:55 pm #1074392Hi,
I took another look, the class was being added, but the middle if statement was not executing, I thought it was before.
Anyways I found out that you can’t use “if”, or “else if” that way, it must be “else” like this:(function($) { $(document).ready(function(){ if ($("body").hasClass("news-cat")) { $('.avia-post-nav').css({ 'display': 'block' }); } else ($("body").hasClass("artists-cat")) { $('.avia-post-nav').css({ 'display': 'block'}); } else ($("body").hasClass("writers-cat")) { $('.avia-post-nav').css({ 'display': 'block'}); } else { $('.avia-post-nav').css({ 'display': 'none'}); } }); })(jQuery);
This seems to work now, please check.
Best regards,
MikeMarch 5, 2019 at 12:55 pm #1074852You are a champ Mike!
Looks like it is working no and you can close it.Thank you.
March 6, 2019 at 5:18 am #1075260Hi,
Glad to hear it’s working and that we were able to help, we will close this now. Thank you for using Enfold.For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)Best regards,
Mike -
AuthorPosts
- The topic ‘Previous and next post navigation – want to add another 2 categories’ is closed to new replies.