Auto Also Read Post Adder For Blogger
Table of Contents
Blogger
Blogger is best platform for newbie who want to start a free website for earning money.
Blogger will be best choice for everyone who don’t have custom domain and want to monetize website
- Features of blogger
- Not required any custom domain
- Easy Adsense Approval
- Not Required Hosting
- Easy Interface
- Not required Lots Of Knowledge
So Here is the code which will add also read widget which provide random posts
Benefits Of This
- Engage users
- increase read time
- Provide extra page views
- Incrrease ads impression
- Improve your seo
- Increase page view
Installation
Installation is very easy
- Go to blogger dashboard
- Select your website
- Go to layout
- Click on add a gadget
- Select html/JavaScript
- Copy paste the code
- Make sure you have updated the link
Change this ‘https://YOUR-BLOG-URL’ on script with your blog url
Don’t update full url only update domain
Let me know if you face any error
![](https://www.d3vx.in/wp-content/uploads/2023/09/Screenshot-2023-09-04-220416.png)
It will Look Like This
<div id="random-posts-container">
<h2 class="random-posts-heading">Also Read</h2>
<div id="random-posts">
<!-- This div will display the random posts -->
</div>
</div>
<style>
/* Style the random posts container */
#random-posts-container {
background-color: #f0f0f0;
padding: 20px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* Style the random posts heading */
.random-posts-heading {
font-size: 24px;
color: #ff0000; /* Red color for the heading */
margin-bottom: 10px;
}
/* Style the random post links */
#random-posts a {
display: block;
margin-bottom: 10px;
font-size: 18px;
color: #007bff; /* Blue color for post links */
text-decoration: none;
transition: color 0.3s;
}
#random-posts a:hover {
color: #0056b3; /* Hover color for post links */
}
</style>
<script type="text/javascript">
function displayRandomPosts(data) {
var randomPosts = [];
var maxPosts = 5; // Change this to the number of random posts you want to display
for (var i = 0; i < maxPosts; i++) {
var randomIndex = Math.floor(Math.random() * data.feed.entry.length);
var postTitle = data.feed.entry[randomIndex].title.$t;
var postLink = data.feed.entry[randomIndex].link[4].href;
randomPosts.push('<a href="' + postLink + '">' + postTitle + '</a>');
data.feed.entry.splice(randomIndex, 1);
}
document.getElementById('random-posts').innerHTML = randomPosts.join('');
}
</script>
<script src="https://YOUR-BLOG-URL/feeds/posts/default?alt=json-in-script&max-results=100&callback=displayRandomPosts"></script>
Make sure to replace YOUR-BLOG-URL
with the actual URL of your Blogger blog.
Conclusion
This code fetches a list of posts from your blog’s feed and then randomly selects and displays a specified number of post titles with links. It will engage more users to your blog and also increase page impression. I hope you are liking our posts . donate us some money to keep website active.