Help > Forum > トピック&投稿 > 各投稿の横に投稿番号を表示する
各投稿の横に投稿番号を表示する
以下の手順を使用して、トピック内の各投稿の横に投稿番号を表示できます。
通常、返信でその投稿を参照したい場合は、投稿内の返信リンクを使用する方が適切です。読者が簡単にジャンプできるように、元の投稿へのリンクが自動的に含まれます。後で投稿を削除すると投稿番号が変わる可能性があるため、この方法は投稿番号を記載するよりも信頼性が高くなります。各投稿の共有アイコンを使用して、その投稿への直接リンクをコピーすることもできます。
- Website Toolboxアカウントにログインします。
- をクリックします 統合 メインメニューのリンク。
- をクリックします HTML リンク。
- 以下の HTML コードを、にコピーします。 フォーラムヘッドタグ HTML コード テキストボックス:
<!-- Add post numbers next to each post of a topic. ie: #1, #2, #3 --> <script> window.addEventListener("DOMContentLoaded", function () { const container = document.querySelector('#posts-list'); if (!container || !window.location.href.match(/\/post\//)) return; const observer = new MutationObserver(function (mutations) { let shouldRenumber = false; for (const m of mutations) { for (const node of m.addedNodes) { if (node.nodeType !== 1) continue; if (node.matches && node.matches('.post-body.pull-left')) shouldRenumber = true; else 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') shouldRenumber = true; } } if (shouldRenumber) renumberPosts(); }); function renumberPosts() { observer.disconnect(); let start = 1; const pageText = jQ('.page-numbers').text() || ''; var paginationNum = pageText.replace(/,/g, ""); const matches = paginationNum.match(/[0-9]+/); if (matches) start = parseInt(matches[0], 10); let postNumber = start; if(start > 1) { postNumber = start - 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'); } else { optionsElement.append('#' + postNumber + ''); } postNumber++; } }); observer.observe(container, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); } renumberPosts(); observer.observe(container, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); }); </script> - [保存] 変化。
If you still need help, please contact us.