• Site URL: https://7c8.96a.myftpupload.com/
    WordPress Version: 4.2.2
    Has Your Theme Been Modified: Yes

    Hello, I’m trying to modify a site that was created previous to me.

    They set up a section on the home page called “home-squares” that is the deposit for new posts. Currently it shows any new post created that is categorized as either “recipe” or “whats new”.

    I wanted to divide the sections into two separate depositories. So I copied the php code for the section “recipe”, to create another section called, “whats new” and replaced it’s title in this code area. <?php esc_html_e(‘Whats New?’,’EarthlyTouch’); ?>

    Unfortunately it’s not differentiating. Even if I go to the posts and select just one of those categories they still show up in either section.

    Can you tell me how and where I can alter the code so that the posts will show in their correct category and not in both? I am not a php developer. Thanks a lot

    [ Moderator note: Code fixed, please wrap code in backticks or use the code button. ]

    <?php get_header(); ?>
    
    <div id="containerHOME">
    <div id="left-div">
    <div id="left-inside">
    <?php if (get_option('earthlytouch_featured') == 'on') get_template_part('includes/featured'); ?>
    
    <?php if (get_option('earthlytouch_show_random_posts') == 'on') { ?>
    <div class="clear">?</div>
    <div class="home-squares">
    <div class="home-headings">
    <?php esc_html_e('Whats New?','EarthlyTouch'); ?>
    </div>
    <?php $randomArticlesNum = (int) get_option('earthlytouch_randomposts_num');
    
    query_posts("cat=25&orderby=DESCd&showposts=3&$randomArticlesNum&caller_get_posts=1");
    
    while (have_posts()) : the_post(); ?>
    <div class="random">
    <?php $width = 40;
    
    $height = 40;
    
    $classtext = 'no-border';
    
    $titletext = get_the_title();
    
    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    
    $thumb = $thumbnail["thumb"]; ?>
    <?php if($thumb != '') { ?>
    <div class="random-image"> <a>"> <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?> </a> </div>
    <?php }; ?>
    <a>" rel="bookmark" title="<?php printf(esc_attr__('Permanent Link to %s','EarthlyTouch'), the_title()) ?>">
    <?php truncate_title(40); ?>
    </a>
    <?php truncate_post(50); ?>
    </div>
    <!-- end .random -->
    
    <?php endwhile; wp_reset_query(); ?>
    </div>
    <!-- end .home-squares -->
    
    <!-- begin recipes .home-squares 2 -->
    <div class="home-squares">
    <div class="home-headings">
    <?php esc_html_e('Recipes','EarthlyTouch'); ?>
    </div>
    <?php $randomArticlesNum = (int) get_option('earthlytouch_randomposts_num');
    
    query_posts("cat=25&orderby=DESCd&showposts=3&$randomArticlesNum&caller_get_posts=1");
    
    while (have_posts()) : the_post(); ?>
    <div class="random">
    <?php $width = 40;
    
    $height = 40;
    
    $classtext = 'no-border';
    
    $titletext = get_the_title();
    
    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
    
    $thumb = $thumbnail["thumb"]; ?>
    <?php if($thumb != '') { ?>
    <div class="random-image"> <a>"> <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?> </a> </div>
    <?php }; ?>
    <a>" rel="bookmark" title="<?php printf(esc_attr__('Permanent Link to %s','EarthlyTouch'), the_title()) ?>">
    <?php truncate_title(40); ?>
    </a>
    <?php truncate_post(50); ?>
    </div>
    <!-- end .random -->
    
    <?php endwhile; wp_reset_query(); ?>
    </div>
    <!-- end .home-squares -->
Viewing 1 replies (of 1 total)
  • Thread Starter boplinger

    (@boplinger)

    Or better said: How to display two random-post sections that are each under their own category

Viewing 1 replies (of 1 total)
  • The topic ‘How to display two separate categoried -random posts in 2 sep sections’ is closed to new replies.