How to Add Stylish Middle Related Posts Accordion in your Blog Post
Related Articles in the middle of your Blog posts will be helpful for your visitors as it will show a list of more matching articles.
Estimated read time: 7 min
Hello! Welcome to Fineshop Blog.
If you want to optimize your traffic and prompt your visitors to read more articles on your blog, adding Related Posts Accordion in the middle of your Blog Post will surely help you to achieve this.
Related Posts Accordion for Blogger Blog Posts
© Fineshop Blog | Related Posts Accordion
Today, we will make a Stylish Related Posts Accordion that can be added anywhere in the middle of your Blogger Blog Posts. It will be helpful for your visitors because it will show a list of articles matching with what they are currently reading. As it will show related posts, so there will be more chances that the visitor will click on that related article.
How to Add Related Posts Accordion?
Adding Related Posts Accordion in your Blog Post will not require much knowledge about HTML, CSS or JS because I have already designed it for you. What you need to do is to implement the codes at right place in your Blogger Theme XML and add the Related Posts Accordion HTML Codes in the middle of your posts.
Important!
Before we start adding codes in XML, I will recommend you to take a Backup of your current theme. By chance if any problem occurs, you can restore it later.
Step 1: First of all Login to your Blogger Dashboard.
Step 2: On Blogger Dashboard, click Theme.
Step 3: Click the arrow down icon next to 'customize' button.
Step 4: Click Edit HTML, you will be redirected to editing page.
Step 5: Now search the code ]]> and paste the following CSS Codes just above to it.
If your template has a dark mode feature, and if you want a different color when in dark mode, you can customise the codes as per your need. Each template can have a different dark mode class, so please adjust it, you can replace the marked class with your template dark mode class.
/* Accordion by Fineshop */
.acdn{position:relative;list-style:none;margin:30px 0;padding:0;font-size:14px;line-height:1.7em;font-family:inherit}
.acdn .ac{width:100%;padding:20px 0 20px 15px;margin:10px 0;background:#f0f0ff;border-radius:10px;border-left:4px solid #8a8aff;box-shadow:0 5px 10px rgba(51,51,51,.1)}
.acdn .ac:nth-child(4n + 1){background:#f0f0ff;border-left-color:#8a8aff}
.acdn .ac:nth-child(4n + 2){background:#fff0f3;border-left-color:#ff8aa1}
.acdn .ac:nth-child(4n + 3){background:#f0faff;border-left-color:#8ad8ff}
.acdn .ac:nth-child(4n + 4){background:#fff7f0;border-left-color:#ffc08a}
.acdn .cont{margin:0;padding-left:27px;padding-right:27px;position:relative;overflow:hidden;max-height:0;transition:all .3s ease;color:#08102b}
.acdn .cont ul, .acdn .cont ol{padding-left:13px}
.acdn .cont li{padding:0}
.acdn .cont a{text-decoration:none;color:#08102b}
.acdn .cont a:hover{text-decoration:underline}
.acdn p:first-child{margin-top:0}
.acdn p:last-child{margin-bottom:0}
.acTtl{display:flex;align-items:center;font-weight:700;color:#08102b}
.acTtl span{display:flex;flex-grow:1}
.acTtl span:before{content:'';padding-left:15px}
.acIcn{flex-shrink:0;display:flex;align-items:center;width:12px;height:12px;position:relative}
.acIcn:before, .acIcn:after{content:'';display:block;width:100%;height:2px;border-radius:2px;background:#08102b}
.acIcn:after{position:absolute;transform:rotate(90deg)}
.acMn{display:none}
.acMn:checked ~ .acTtl .acIcn:after{visibility:hidden;opacity:0}
.acMn:checked ~ .cont{max-height:100vh;padding-top:15px;padding-bottom:8px}
.darkMode .acdn .ac{background:#252526;border-left-color:#4c4c4e}
.darkMode .acdn .cont, .darkMode .acdn .cont a, .darkMode .acTtl, .darkMode .acMn:checked ~ .acTtl{color:#fefefe}
.darkMode .acTtl .acIcn:before, .darkMode .acTtl .acIcn:after, .darkMode .acMn:checked ~ .acTtl .acIcn:before, .darkMode .acMn:checked ~ .acTtl .acIcn:after{background:#fefefe}
Step 6: After doing so, search the code and paste the following Codes just above to it.
Change the marked parts
10: Maximum no. of related posts (eg. 15)
auto: Maximum no. of title characters (eg. 30), leave it auto for full title
false: Replace with true if you want to open related posts in New Tabs
Step 7: Add the following Codes just below to .
Step 8: Save the changes by clicking on this icon
That's done! Now add the following HTML Codes in your Blog Posts wherever you want to show Related Posts Accordion.
Related Posts are shown as per Posts' Labels.
Alternative Usage
You can use this as Accordion in your posts also, for that use the following HTML codes:
...
...
...
...