Puoi utilizzare i passaggi seguenti per mostrare un numero di post accanto a ogni post in un argomento.
In genere è meglio utilizzare il link di risposta all'interno di un post quando si desidera fare riferimento a quel post nella risposta. Ciò include automaticamente un collegamento al post originale in modo che i lettori possano accedervi facilmente. Questo approccio è più affidabile rispetto alla menzione di un numero di post, poiché i numeri dei post possono cambiare se alcuni post vengono rimossi in seguito. Puoi anche utilizzare l'icona di condivisione in ogni post per copiare un link diretto ad esso.
Passaggi per mostrare i numeri dei post
- Accedi al tuo account Website Toolbox.
- Fai clic su Integra link nel menu principale.
- Fai clic su Codice personalizzato collegamento.
- Copia il codice HTML qui sotto nel Codice HTML del tag principale del forum casella di testo:
window.addEventListener («DOMContentLoaded», function () { contenitore const = document.querySelector ('#posts -list'); se (! contenitore ||! window.location.href.match (/\ /post\//)) restituisce; const observer = new MutationObserver (funzione (mutazioni) { let shouldreNumber = false; for (composto da milioni di mutazioni) { for (nodo const di m.addedNodes) { if (node.nodeType! == 1) continua; if (node.matches && node.matches ('.post-body.pull-left')) dovrebbe essere numerato = vero; altrimenti if (node.querySelector && node.querySelector ('.post-body.pull-left')) shouldreNumber = true; if (node.id && node.id.startsWith ('post_row_')) { const el = document.getElementById (node.id); if (el && window.getComputedStyle (el) .display === 'none') shouldreNumber = true; } } if (m.type === 'attributes' && m.target.id && m.target.id.startsWith ('post_row_')) { const el = m.target; if (el && window.getComputedStyle (el) .display === 'none') should Number = true; } } if (should Number) renumberPosts (); }); funzione renumberPosts () { observer.disconnect (); let start = 1; const pageText = jQ ('.page-numbers') .text () || «; var paginationNum = pageText.replace (/, /g, «»); const corrispondenze = paginationNum.match (/[0-9] +/); if (corrisponde) start = parseInt (corrisponde a [0], 10); lascia che postNumber = inizi; if (start > 1) { postNumber = inizio - 1; } jQ ('#posts -list .post-body .post-options') .each (function () { const optionsElement = jQ (this); if (optionsElement.closest ('.post-body') .is (':visible')) { optionsElement.find ('.post-number') .remove (); if (optionsElement.closest ('.first-post') .length) { optionsElement.append ('#1'); } altro { optionsElement.append ('#' + postNumber +' '); } Numero di posta++; } }); observer.observe (container, {childList: true, sottoalbero: true, attributes: true, attributeFilter: ['style', 'class']}); } rinumera post (); observer.observe (container, {childList: true, sottoalbero: true, attributes: true, attributeFilter: ['style', 'class']}); }); - Salva le modifiche.