
-
AuthorPosts
-
February 21, 2022 at 6:45 pm #1341713
In the “Magazine element”, the posts from different categories are displayed. Some posts are in the same category.
If I now display the contents via the table of contents, the posts in the same categories are of course also displayed several times in the table of contents.
Can this be prevented somehow?February 22, 2022 at 6:00 am #1341752Hey Fischpi,
Thank you for the inquiry.
We cannot find the TOC element or widget in the page. Are you using a different plugin for the TOC? Please provide a screenshot of the TOC element using imgur or dropbox so that we can check it properly.
Best regards,
IsmaelFebruary 22, 2022 at 8:41 am #1341755I’m using the enfold widget toc and also alternatively “LuckyWP Table of Contents”. Both have the “Same problem”. See Screenshot in private content area
February 23, 2022 at 3:54 am #1341900Hi,
Thank you for the info.
In the Magazine element, there is an Offset Number settings in the Styling > Pagination section where you can disallow duplicate posts on the entire page. Please set it to the second option to remove the duplicate posts.
Best regards,
IsmaelFebruary 23, 2022 at 8:49 am #1341953Hi Ismael,
but your suggested setting does not change anything (see screenshot). Do you need login data to have a closer look?
February 24, 2022 at 9:14 am #1342119Hi,
Yes, please post the login details in the private field so that we can check the settings. Did you try purging the cache after editing the magazine elements’ offset settings?
Best regards,
IsmaelFebruary 25, 2022 at 8:05 am #1342241See attached
February 28, 2022 at 3:15 am #1342506Hi Fischpi,
Thanks for providing us with admin access.
It seems to be a bug with TOC when using magazine element when multiple categories are selected.
We’ll report it to our devs.Best regards,
NikkoMarch 6, 2022 at 8:26 am #1343329Hi Nikko,
any news from the devs?
Dirk
March 6, 2022 at 9:39 pm #1343386Hi,
Thank you for your patience, unfortunately, the DEV Team explains that it is not possible to combine TOC and Magazine with two or more categories selected due to technical reasons.
I tested this script on the page you linked to and it seems to remove the duplicate links from the TOC, you can try it and see if it helps.
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function remove_duplicate_toc_links() { ?> <script> (function($) { setTimeout(function(){ var linksHtml=[]; $('.avia-toc-container a').each(function() { var html=$(this).html(); if( $.inArray( html, linksHtml) >-1){ $(this).remove() }else{ linksHtml.push(html); } }); },500); }(jQuery)); </script> <?php } add_action('wp_footer', 'remove_duplicate_toc_links');
Best regards,
MikeMarch 6, 2022 at 10:43 pm #1343394Hi Mike,
thanks a lot it’s working! Other question: Is it possible to Collapse/Expand the Enfold-TOC?
Dirk
March 6, 2022 at 11:54 pm #1343398Hi,
Glad to hear, you can try this script to toggle the TOC, I wrote it for this one page so I’m not sure if you have others. Clicking on the title toggles and I included some css to show a green arrow up/down to let users know. On page load it’s toggled but this can be changed.
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:function toggle_toc_container() { ?> <script> (function($){ $('#avia_auto_toc-2 .avia-toc-container').hide(); $('#avia_auto_toc-2 > h3.widgettitle').click(function(e){ e.preventDefault(); var $this = $('.avia-toc-container'); $this.toggle(); $("#avia_auto_toc-2 > h3.widgettitle").toggleClass( "up" ); }); })(jQuery); </script> <?php } add_action('wp_footer', 'toggle_toc_container');
and this to your Quick CSS
#avia_auto_toc-2 > h3.widgettitle:before { content: "\2BC6 "; color: #42a51e; } #avia_auto_toc-2 > h3.widgettitle.up:before { content: "\2BC5 "; color: #42a51e; }
Best regards,
MikeMarch 7, 2022 at 11:39 am #1343460Hi Mike,
thanks for CSS code but Collapse/Expand doesn’t work?
Dirk
March 7, 2022 at 2:01 pm #1343482Hi,
I see that you forgot to also add the script above to your child theme functions.php, I did this for you, please check.Best regards,
MikeMarch 7, 2022 at 2:47 pm #1343495Hi Mike,
thanks. Its working. I have seen that you have added the page-id in the functions.php. What must be changed / added in the code if I want to output the toc on another page?
Dirk
March 7, 2022 at 3:03 pm #1343499Hi,
If you want to use this for other pages I recommend adding a custom ID to the toc to replace to auto generated avia_auto_toc-2 ID then in the script and css replace the page ID and #avia_auto_toc-2 with the new ID.
Or since this is added via the widget element to the pages you could try just removing the page ID from the script.Best regards,
MikeMarch 7, 2022 at 5:25 pm #1343526Hi Mike,
thanks. It’s working ;-)!
Dirk
March 8, 2022 at 2:54 am #1343549Hi,
Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.Best regards,
Mike -
AuthorPosts
- The topic ‘Double headings in the table of contents’ is closed to new replies.