• Resolved Daisy Olsen

    (@daisyo)


    I have created the visual effect and content that I want displayed on the site https://blissfullydomestic.com but the page ends up with 186 queries I need to try to find a more efficient way to accomplish this layout.

    I have 15 top level categories. I need to display them in a grid with 3 columns and 5 rows displaying the following:

    1. category image linking to the category archive
    2. Rss image linking to category feed
    3. last 5 post titles linking to posts

    Here is one column of code from the index.php file

    <div id="leftcol">
        <?php
    // enter the IDs of which categories you want to display
    $display_categories = array(22,31,76,32,88);
    foreach ($display_categories as $category) { ?>
        <div class="clearfloat">
          <?php query_posts("showposts=5&cat=$category");
    	    $wp_query->is_category = false;
    		$wp_query->is_archive = false;
    		$wp_query->is_home = true;
    		 ?>
    <?php $getcategory = $wp_query->get_queried_object();
     $getcategory->category_nicename; ?>
         <div class="category-icon"> <a href="<?php echo get_category_link($category);?>">
    <img src="https://blissfullydomestic.com/wp-content/images/icons2/<?php echo $category ?>.png">
            </a></div>
    <div class="rss-icon"><a href="<?php echo get_category_link($category);?>feed "><img src="https://blissfullydomestic.com/wp-content/themes/blissfullydomestic/images/rss.png"></a> </div>
    <br style="clear:both"/>
    <div class="editor"><?php echo category_description($category); ?></div>
    <br style="clear:both"/>
    <div class="recent-posts"><ul>
          <?php while (have_posts()) : the_post(); ?>
    
    <li><a href="<?php the_permalink() ?>" rel="bookmark"  class="title" title="Permanent Link to <?php the_title(); ?>"><?php the_title2('', '...', true, '40') ?></a></li>
    
          <?php endwhile; ?></ul></div>
        </div>
        <?php } ?>
      </div>
      <!--END LEFTCOL-->

    I appreciate all suggestions and feedback!

Viewing 1 replies (of 1 total)
  • Anonymous User

    (@anonymized-473288)

    That looks pretty cool.

    Possible solution:

    1. Copy and paste the browser source output of the file in your index.php/ home.php so that you have static html instead of the php functions.

    2. Use static html for the stuff that almost never changes for example the categories and the links at the top of the page.

    3. Keep the php for the posts, or write a function which writes to a static file at the click of a button or at a set time interval and possible use php include files to include the created static html files.

    4. Keep a backup of the file somewhere so that you can easily print the sections if the categories or any other information changes.

    5. Write a function that does this all this automatically at the click of a button or at a set interval (for example once an hour or once a day) with the result a static html file.

    Of course the total sum of the php calls run would have to be (significantly) less than the amount you have running now.

Viewing 1 replies (of 1 total)
  • The topic ‘Looking for a more efficient way to code this page…’ is closed to new replies.