Implement a grid layout for columns within the profile section

Each user on my website has a profile tab that displays their submitted posts.

To showcase these posts, I utilize the following code:

<?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop->the_post(); $post_id = get_the_ID(); ?>

    <div class="um-item">
        <div  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>

        <?php if ( has_post_thumbnail( $post_id ) ) {
                $image_id = get_post_thumbnail_id( $post_id );
                $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
        ?>

        <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>

        <?php } ?>

        <div class="um-item-meta">
            <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
            <span>in: <?php the_category( ', ' ); ?></span>
            <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
        </div>
    </div>


<?php } ?>

Despite this setup, the display of each post is stacked one below the other in a single column. My goal is to present them in a grid-like format with two or three adjacent columns instead. To experiment with this, I initially attempted the following:

<?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop->the_post(); $post_id = get_the_ID(); ?>

        <div id = "left" class="um-item">
            <div  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>

            <?php if ( has_post_thumbnail( $post_id ) ) {
                    $image_id = get_post_thumbnail_id( $post_id );
                    $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
            ?>

            <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>

            <?php } ?>

            <div class="um-item-meta">
                <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
                <span>in: <?php the_category( ', ' ); ?></span>
                <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
            </div>
        </div>

        <div id = "right" class="um-item">
            <div style="height: 10px;  class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>

            <?php if ( has_post_thumbnail( $post_id ) ) {
                    $image_id = get_post_thumbnail_id( $post_id );
                    $image_url = wp_get_attachment_image_src( $image_id, 'full', true );
            ?>

            <div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'thumbnail' ); ?></a></div>

            <?php } ?>

            <div class="um-item-meta">
                <span><?php echo sprintf(__('%s ago','ultimatemember'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
                <span>in: <?php the_category( ', ' ); ?></span>
                <span><?php comments_number( __('no comments','ultimatemember'), __('1 comment','ultimatemember'), __('% comments','ultimatemember') ); ?></span>
            </div>
        </div>

    <?php } ?>

The layout was not successful as everything appeared broken and messy. How can this be enhanced? My aim is to create a structured post grid like this:

Post 1     Post 2      Post 3

Post 4     Post 5      Post 6

Post 7     Post 8      Post 9

Post 10    Post 11    Post 12

Thank you for your valuable assistance.

Answer №1

Have you considered utilizing a table? Utilizing a CSS framework such as bootstrap allows you to easily apply the "col-md-4" class for proper styling.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Activate Jquery as the user navigates through it with scrolling

Is there a way to activate a JQuery event when the user first scrolls over a particular div? I attempted to utilize waypoint for this purpose, but unfortunately, it did not work as expected. Below is the code I used with no errors: var waypoints = $(&apo ...

Converting CSV to Json while using the first row as the key

Is there a way to convert a CSV file into JSON format using the header row as key and each line as an object? ----------------------------------CSV--------------------------------- InvKey,DocNum,CardCode ABC123,001,Alice DEF456,002,Bob GHI789,003,Cha ...

Blur effect on backdrop-filter causing shadowy inset borders (specific to Chrome and Windows)

Note: The issue mentioned below has been resolved in the latest version of Chrome (119.0.6045.200). While transitioning on backdrop-filter, I have observed a dark inset shadow that is only visible during the transition. This behavior seems to occur only ...

What are the most effective strategies for efficiently handling enormous json files?

I have a substantial amount of data stored in JSON format. I am considering the best approach to manage this data, such as loading it into MongoDB or CouchDB on a remote host like Mongolab, using a flat-file JSON database like , parsing the files directl ...

A guide to using Angular to emphasize text based on specific conditions met

Currently, I am developing a testing application that requires users to choose radio type values for each question. The goal is to compare the selected answers with the correct answers stored in a JSON file. To achieve this, I have implemented an if-else ...

Responsive design with Flexbox, interactive graphics using canvas, and dynamic content resizing

I'm having difficulties with my canvas-based application. I have multiple canvases, each wrapped in a div container alongside other content. These containers are then wrapped in an "hbox" container. The objective is to create a dynamic grid of canvas ...

What is the best way to obtain validation when saving multiple records using newEntities() in CakePHP 3.x?

Whenever I attempt to save multiple records, I am not receiving any validation errors. Even though I can retrieve the errors by using print_r($user->errors());, they are not automatically displayed in the form like they are when saving a single user. The d ...

Unable to click on element in Firefox browser

Encountering an issue with the following error message: Element is not clickable at point (791, 394). Other element would receive the click: Command duration or timeout: 66 milliseconds Any ideas on what's causing this? Using selenium web driver ve ...

My initial experiment with jquery/ajax fails to yield the desired results

I've been experimenting with incorporating more jQuery/Ajax into my web projects. As a test, I tried the following: <div id="main_content"></div> <div class="panel panel-primary"> <div class="panel-heading">Remaining API C ...

Update the content within a div based on the selected option from a dropdown menu or

Is there a way to change the displayed text based on user input or selected option? By default, the text shown is "Aa Bb Cc Dd Ee...", but it can be changed by selecting different options. If text is typed into the input field, the displayed text will up ...

Leveraging visual content in Pryocms channels

I am currently facing an issue with a plugin that is responsible for rendering stream information on my pyrocms site. The problem lies in rendering the image uploaded using the image filetype. Despite trying multiple approaches, none of them seem to work ...

Issues with Adding Variable Products to Cart in Woocommerce

Hey there! I've been working on my woocommerce website and have added a variety of products, some single and some variable. The singles are all good to go, but I've run into an issue with the variable ones. Every time I try to add a variable prod ...

Selenium - How to effectively obtain hyperlinks?

There are numerous web elements similar to this example <a data-control-name="browsemap_profile" href="/in/quyen-nguyen-63098b123/" id="ember278" class="pv-browsemap-section__member ember-view"> <img widt ...

How do I input text into a Google Doc using an XPATH or element that is difficult to manipulate?

I'm currently working on a Python code that is designed to automatically open a Google Doc and input a specific set of combinations for a predetermined length. While I've successfully created the code to navigate to my Google Docs and open a new ...

How can I prevent scrolling in a Vue mobile menu?

In this scenario, the toggle for the menu is controlled by a checkbox with the id "check" below. I attempted to bind v-bind:class="[{'antiscroll': checkboxValue}]" to the body in HTML, and also in the main App.vue file, but it did not work as exp ...

Choose a sibling element using CSS styling

As I'm developing an AngularJS component, I am on the quest to identify ANY sibling of a particular tag, irrespective of whether they are div, span, or p. I'm hoping for a CSS-native solution that resembles something along the lines of div:siblin ...

Troubleshooting Issue with Ionic's UI Router

Recently, I created a basic Ionic app to gain a better understanding of UI router functionality. To my surprise, when I ran the app, nothing appeared on the screen. Additionally, the developer tools in Google Chrome did not show any errors or information. ...

PHP not receiving POST information from $.ajax call

My JavaScript triggers a POST method when the datepicker loses focus, calling the script rent-fetch-pick-up-point.php. However, the PHP script gets stuck at the if-statement because it's not receiving the POST data. The datepicker is associated with a ...

Limit selection choices in select element

Similar Question: Prevent select dropdown from opening in FireFox and Opera In my HTML file, I have a select tag that I want to use to open my own table when clicked. However, the window of the Select tag also opens, which is not desirable. Is there a ...

Tips for creating a responsive React Monaco Editor:

I'm currently working with react-monaco-editor and having trouble making it responsive. The component has a fixed height and width, so when I resize the screen, the width stays the same. <MonacoEditor width="1200" height=& ...