Crear Caja de Posts Relacionados sin Plugins en WordPress

Manuel Campos

En esta publicación te enseñare a crear una caja de posts relacionados en tu sitio de WordPress sin la necesidad de instalar un plugin


/*CSS for Related Posts*/
.outer-related-posts-container {
    background-color: #f5f8fc;
    padding-top: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.related-posts-container {
    max-width: 1200px;
    margin: 0 auto;
}
.widget-title {
    font-size: 30px;
    font-weight: 700;
    color: #333;
    margin-bottom: 30px;
}
.related-posts-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}
.related-posts-list li {
    width: calc(33.33% - 10px);
    margin-bottom: 20px;
}
.title {
    text-decoration: none;
    color: #0073e7;
}
.title h4 {
    font-size: 21px;
    line-height: 1.8;
    text-align: center;
    margin: 10px auto;
    max-width: 280px;
    font-weight: 700;
}
.thumb img {
    width: 320px;
    height: 240px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
    margin: 0 auto;
}
.modified-date {
    font-size: 14px;
    color: #555;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}
@media (min-width: 767px) and (max-width: 867px) {
    .outer-related-posts-container {
        padding: 10px;
        margin: 0 auto;
    }
    .related-posts-list li {
        width: 100%;
        margin-left: -30px;
    }
    .thumb img {
        width: 80%;
        height: auto;
        object-fit: cover;
        border-radius: 12px;
        display: block;
        margin: 0 auto;
    }
    .title h4 {
        text-align: center;
        max-width: 100%;
        margin: 10px 0;
    }
}
@media (max-width: 766px) {
    .outer-related-posts-container {
        padding: 10px;
        margin: 0 auto;
    }
    .related-posts-list li {
        width: 100%;
        margin-left: -30px;
    }
    .thumb img {
        width: 100%;
        height: auto;
        object-fit: cover;
        border-radius: 12px;
        display: block;
        margin: 0 auto;
    }
    .title h4 {
        text-align: center;
        max-width: 100%;
        margin: 10px 0;
    }
}
Manuel Campos, English Professor

Manuel Campos

I am José Manuel. I am writing about things I know and things that I am learning about WordPress. I hope you find the content of this blog useful.

WP SURFER

home

about

privacy

contact

© 2024 WP SURFER • Made with Love in Costa Rica