How to add page post with photo and title in blogspot

 


You can show multiple post using this java script in your website . just copy the code and paste in gadget section add html/java script 


<script>

// Blogger Feed URL (Replace 'your-blog-name' with your actual blog's name)

const blogUrl = "https://thedaily71.blogspot.com/feeds/posts/default?alt=json&max-results=100";


// Function to fetch and display posts

async function fetchBlogPosts() {

    try {

        const response = await fetch(blogUrl);

        const data = await response.json();

        const entries = data.feed.entry.slice(0, 100); // Limits the number of posts to 100

        let htmlContent = "";


        entries.forEach(entry => {

            const title = entry.title.$t;

            const link = entry.link.find(l => l.rel === "alternate").href;

            const content = entry.content ? entry.content.$t : "";

            const imgMatch = content.match(/<img.*?src=['"](.*?)['"]/);

            const imgSrc = imgMatch ? imgMatch[1] : "https://via.placeholder.com/150"; // Default image if none found


            htmlContent += `

                <div class="post-box">

                    <a href="${link}" >

                        <img src="${imgSrc}" alt="${title}" />

                        <h3>${title}</h3>

                    </a>

                </div>

            `;

        });

        

        document.getElementById("blog-posts").innerHTML = htmlContent;

    } catch (error) {

        console.error("Error fetching blog posts:", error);

    }

}


// Run function on page load

fetchBlogPosts();

</script>


<style>

    #blog-posts {

        display: grid;

        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));

        gap: 15px;

    }

    .post-box {

        border: 1px solid #ddd;

        padding: 10px;

        text-align: center;

        background: #fff;

        box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);

    }

    .post-box img {

        max-width: 100%;

        height: auto;

    }

    .post-box h3 {

        font-size: 14px;

        margin: 10px 0 0;

    }

</style>


<div id="blog-posts">Loading...</div>

একটি মন্তব্য পোস্ট করুন

0 মন্তব্যসমূহ

সিঙ্গাপুরে ওয়ার্ক পারমিটধারীদের জন্য নতুন নিয়ম: চাকরির মেয়াদ সীমা বাতিল, সর্বোচ্চ বয়সসীমা ৬৩ বছর
বাংলাদেশের মুক্তিযুদ্ধের সঠিক ইতিহাস
সিঙ্গাপুরে ট্রেইনিং রেকর্ড এবং সার্টিফিকেট চেক করার বিস্তারিত গাইড
Bangla date add in your website HTML tips.
some common interview questions and answers for a Safety Coordinator position in Singapore
ধর্ষণবিরোধী বিক্ষোভে উত্তাল তিন বিশ্ববিদ্যালয়, শিক্ষার্থীদের আল্টিমেটাম
Understanding the New Demerit Point System for Construction and Manufacturing Sectors
Safe work procedure for ferrying workers by lorry in singapore
বাংলাদেশি শ্রমিকদের জন্য সিঙ্গাপুরে কম খরচে দাঁতের চিকিৎসা
সিঙ্গাপুর কর্মস্থলের নিরাপত্তা আইন শক্তিশালী করছে এবং নতুন আইন প্রবর্তন করছে
Loading posts...