Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:01:49+00:00 2026-06-04T10:01:49+00:00

This is the standard HTML code I have and I’m trying to merge it

  • 0

This is the standard HTML code I have and I’m trying to merge it into a WordPress loop that basically displays posts in two different ways. I’m using more fields plugin for the user to choose one of two ways of displaying the post. 1) If they choose Large, the post gets wrapped with the div class ‘large link’ 2) If the user chooses ‘Small’, a div with the class ‘groupOflinks’ is created and the post is wrapped with a div class ‘smallLink’. Only 4 ‘smallLink’ div’s/posts can be held within one ‘groupOflinks’ div. If there are more than 4 Small posts a new ‘groupOflinks’ div is created and the process is repeated.

Here is the HTML code i’m trying to merge (heavily commented):

<!-- Display one post within this container only & if there are more posts that have been chosen as Large, wrap them in the 'largeLink' div -->

<div class="largeLink">
    <!-- post 1 content here -->
</div>

<div class="largeLink">
    <!-- post 2 content here -->
</div>

<!-- If a post is defined as small within the admin panel (using more fields plugin) 
     display them within this 'groupoflinks' container 
     If 4 posts are already in this 'groupoflinks' container create a new container and populate with another 4 posts 
     Repeat -->

<div class="groupOfLinks">
    <!-- This is a container that holds 4 posts only & if there are more posts that have been assigned as 'Small' create a new 'groupOflinks' container and populate with the next 4 -->
    <div class="smallLink">
        <!-- Post 4 content here -->
    </div>
    <div class="smallLink">
        <!-- Post 5 content here -->
    </div>
    <div class="smallLink">
        <!-- Post 6 content here -->
    </div>
    <div class="smallLink">
        <!-- Post 7 content here -->
    </div>
</div>

<div class="largeLink">
    <!-- post 3 content here -->
</div>

<div class="largeLink">
    <!-- post 8 content here -->
</div>

This is my WP loop so far that doesn’t quite work:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<?php // Take the value defined with the 'Layout' field and change style accordingly
$layouttype = get_post_meta($post->ID, 'layout-type', true) ?>
<?php if ($layouttype == 'Small') { ?>

<div class="groupOfLinks">

    <!--LOOP STYLE 1 GOES HERE-->
    <?php $temp_query = $wp_query;  // store it
        $args = array(
        'paged' => $paged, // paginates
        'post_type'=>'post',
        'order' => 'DESC'
        );
        $wp_query = new WP_Query($args);
        while ($wp_query->have_posts()) : $wp_query->the_post();?>

        <div class="smallLink">
                        <!-- Post content here -->
                        <h1><?php the_title(); ?></h1>
            <?php the_content(''); ?>
                    </div>


        <?php if (isset($wp_query)) {$wp_query = $temp_query;} // restore loop
              endwhile; ?>

</div>

<?php } else { ?>

<!--LOOP STYLE 2 GOES HERE-->

<div class="largeLink">
        <!-- post 1 content here -->
        <h1><?php the_title(); ?></h1>
        <?php the_content(''); ?>
    </div>


<?php } ?>


<?php endwhile; ?>

<div>
<div><?php next_posts_link('&laquo; Older Entries') ?></div>
<div><?php previous_posts_link('Newer Entries &raquo;') ?></div>
</div>

<?php else : ?>

<h2>Not Found</h2>
<p>Sorry, but you are looking for something that isn’t here.</p>

<?php endif; ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:01:51+00:00Added an answer on June 4, 2026 at 10:01 am

    I have a meeting in a few minutes, so for the sake of time, I’m gonna to just start you in the right direction, you may have to make a few tweaks since I wrote this in a hurry. Let’s start with your loop and make a few quick changes.

    <?php
    //Set a counter to determine if small post has been used
    $small_posts = 0;
    if(have_posts()) :
        while(have_posts()): the_post();
        $layouttype = get_post_meta(get_the_ID(), 'layout-type', true);
        if($layouttype == 'Small') :
            if(($small_posts % 4) == 0) :
                $tmp_query = clone $wp_query; ?>//this line was edited
                <div class="groupOfLinks">
                    <div class="smallLink">
                        <h1><?php the_title(); ?></h1>
                        <?php the_content(); ?>
                    </div>
                    <?php $i = 1;
                    while(have_posts() && $i <=4) : the_post(); 
                        $layouttype = get_post_meta(get_the_ID(), 'layout-type', true);
                        if($layouttype == 'Small') : ?>
                            <div class="smallLink">
                                <h1><?php the_title(); ?></h1>
                                <?php the_content(); ?>
                            </div>
                            <?php $i++; 
                       endif;
                   endwhile; ?>
                   </div>
                   <?php $wp_query = clone $tmp_query;//this line was edited
            endif;//End counter check
            //Whether we needed to enter the subloop or not, the counter is incremented
            $small_posts++;
        else: //Else for if($layouttype == 'Small') ?>
            <div class="largeLink">
                <h1><?php the_title(); ?></h1>
                <?php the_content(); ?>
            </div>
       <?php endif;
       endwhile; ?>
    <div>
        <div><?php next_posts_link('&laquo; Older Entries') ?></div>
        <div><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    </div>
    <?php else : ?>
        <h2>Not Found</h2>
        <p>Sorry, but you are looking for something that isn’t here.</p>
    <?php endif; ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an html table that looks like this in a standard HTML 4.01
I have a standard HTML input that I want to run JavaScript code when
I have some html code that look like this sample here : <html> <body>
I have an issue. I use this code: var test='test'; $('#tip').delay(1000).html(test); That doesn't work,
I'm trying to use this fairly standard line of code in my app: [[UIApplication
So I have some code here that takes user input from a standard web
At the moment I have this (standard) code which gives me a full-width background
I have this HTML code: <td align=center> and I'm getting this error in Visual
I have this little code to extract the #hashtags : $text = 'The standard
Does this code work across all standard compliant C++ compilers (it works with g++)?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.