Forum Replies Created

Viewing 7 replies - 91 through 97 (of 97 total)
  • Thread Starter Zambrano Sergio

    (@sergiozambrano)

    Thank you for your help!

    Is that code php4 dependent?
    I’m using php5 (as far as I know) and I’ve read there are some differences.

    I’m using that code in https://seosumo.com/test
    Remember, I can’t use “single.php” since this is supposed to be a second loop for a page which already loads “the page”.

    Nothing renders. Not even pasted in a generic page with no previous loop.
    1st loop works fine though: “page” loads fine in “sumo” tab, but your second loop doesn’t render a thing.

    ??

    Make sure you are not duplicating your index.php (or single.php or any other) in your server to test them.

    If you did, make sure you replace the pagename at the top of the code, or wp will read the first file it finds matching that name. wp doesn’t use filenames to find s page’s tamplate but that internal code.

    If that’s not the problem… I hope you fix it, since I’ve been helped with a script for a double loop which is doing the same to me (same content for both loops)

    https://www.ads-software.com/support/topic/251068?replies=3#post-1023595

    this loop is the same, just rewinded and used again (here are no different loops) and does what you need on the index page of seosumo.com

    <?php query_posts('showposts=1');
    while (have_posts()): the_post(); ?>
    
    <div class="entry" id="post-<?php the_ID(); ?>">
    
    <div class="postheader">
    <span class="postinfo postdate"><?php the_time('F j, Y'); ?></span>
    <span class="socialb">
    
    </span>
    	<h1 class="typeface-js"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    	<span class="postinfo"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — Posted by <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></span>
    </div>
    	<?php $more = 1; the_content(); ?>
    
    <?php link_pages('<p class="pagenavigator"> ', '
    ', 'next', ' next page', 'previous page '); ?>
    
     	<div class="postfooter postinfo"><?php the_tags(__('Tags: '), ', ', ' — '); ?></div>
        <!-- end Entry --></div>
    
          <?php endwhile; ?>
    
    ... boring html css code and then ...
    
    <?php rewind_posts(); query_posts('offset=1'); while (have_posts()): the_post(); ?>
    
      <div class="excerpt" id="post-<?php the_ID(); ?>">
      <div class="excerptcont">
    <div class="postheader">
    <span class="postinfo"><?php the_time('F j, Y'); ?></span>
    	<h1 class="typeface-js"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1></div>
    
    	<?php the_content(__('(more...)')); ?>
        <!-- end #ecxerptcont --></div>
        <!-- end #ecxerpt --></div>
    <?php endwhile; ?>

    Thread Starter Zambrano Sergio

    (@sergiozambrano)

    First post from each category… did anybody get it working?

    You have to put the content of the hidden text inside a div tag, assign it a class, like .more , and then to put a little Javascript in the “read the whole thing” link like this

    <a>onclick=
    "this.parentNode.parentNode.className+=' expanded';"
    href="javascript://;">abrir</a>

    That will assign the class “expanded” to whatever the great grand-father of that link is. (e.g. the link is inside a paragraph, which is inside your container, which will receive the “expanded” class. You just keep adding or removing .parentNode to match your html structure and make sure to target the parent of the div to hide.

    Then you just create a css rule like

    .more {
    display: none;
    }
    
    .expanded .more {
    display: block;
    }

    You can use a similar structure to hide the “read the full thing” link and inside the hidden div you put another link with an “close” link and a similar script to replace the “expanded” class with “” (empty value) to get the div back to the original state.

    Thread Starter Zambrano Sergio

    (@sergiozambrano)

    The juice of that code is this. Same posts is shown in both loops.

    <?php // this is where the categories get cycled through and the latest X posts of each are displayed
    	$categories = $wpdb->get_results("SELECT $wpdb->terms.term_id AS id, name, description, term_order from $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id WHERE taxonomy = 'category' AND parent = 0 ORDER BY term_order ASC");
    
    	foreach ($categories as $category) { ?>
    		<?php rewind_posts(); query_posts('category_name='.$category->name.'&showposts=1'); } ?>
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<div class="entry multipost" id="post-<?php the_ID(); ?>">
    
    <?php the_date('','<span class="postinfo">','</span>'); ?>
    
    <div class="postheader">
    	<span class="postinfo"><?php the_date('','<h2>','</h2>'); ?></span>
    	<h1 class="typeface-js"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    	<span class="postinfo"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — Posted by <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></span>
    </div>
    	<?php the_content(__('(more...)')); ?>
    
    <?php link_pages('<p class="pagenavigator"> ', '</p>', 'next', ' next page', 'previous page '); ?>
    
     	<div class="postfooter postinfo"><?php the_tags(__('Tags: '), ', ', ' — '); ?></div>
    
    <?php if (is_single()) : ?>
    <div class="footer"><hr /></div>
    <?php comments_template(); // Get wp-comments.php template ?>
    <?php endif; ?>
        <!-- end Entry --></div>
    
          <?php endwhile; else: ?>
    	<div class="entry">
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
        <!-- end Entry --></div>
    
    <?php endif; ?>
          <div class="footer"><hr /></div>
    Thread Starter Zambrano Sergio

    (@sergiozambrano)

    Thank you for your reply!!

    Looks good!, but it doesn’t work.
    I tested it, and I even added a rewind_posts() function and nothing.

    (There was an extra <?php }?> in this script)

    Both queries show the same content: the page.

    See it at https://seosumo.com/test (that’s the only page that loads your script)
    The code goes as follow:

    <?php
    /*
    Template Name: Pages2
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="mainContent" class="showtab1">
      <div id="maincontent1">
          <h2 class="maintabs">
            <big><b>Sumo</b></big>
            <small><a href="javascript:void(0);" onclick="switch_main(2)">Latest Articles</a></small>
            <small><a href="javascript:void(0);" onclick="switch_main(3)">SEO Tools</a></small>
            </h2>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="entry" id="post-<?php the_ID(); ?>">
    
    <h1 class="typeface-js"><?php the_title(); ?></h1>
    	<?php the_content(__('(more...)')); ?>
    
    <?php endwhile; else: ?>
    	<div class="entry">
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <!-- end #entry --></div>
    
          <div class="footer"><hr /></div>
      </div>
    
      <div id="maincontent2">
          <h2 class="maintabs">
            <small><a href="javascript:void(0);" onclick="switch_main(1)">Sumo</a></small>
            <big><b>Latest Articles</b></big>
            <small><a href="javascript:void(0);" onclick="switch_main(3)">SEO Tools</a></small>
            </h2>
    
    <?php // this is where the categories get cycled through and the latest X posts of each are displayed
    	$categories = $wpdb->get_results("SELECT $wpdb->terms.term_id AS id, name, description, term_order from $wpdb->terms INNER JOIN $wpdb->term_taxonomy ON $wpdb->terms.term_id = $wpdb->term_taxonomy.term_id WHERE taxonomy = 'category' AND parent = 0 ORDER BY term_order ASC");
    
    	foreach ($categories as $category) { ?>
    		<?php rewind_posts(); query_posts('category_name='.$category->name.'&showposts=1'); } ?>
    		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    	<div class="entry multipost" id="post-<?php the_ID(); ?>">
    
    <?php the_date('','<span class="postinfo">','</span>'); ?>
    
    <div class="postheader">
    	<span class="postinfo"><?php the_date('','<h2>','</h2>'); ?></span>
    	<h1 class="typeface-js"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    	<span class="postinfo"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — Posted by <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></span>
    </div>
    	<?php the_content(__('(more...)')); ?>
    
    <?php link_pages('<p class="pagenavigator"> ', '</p>', 'next', ' next page', 'previous page '); ?>
    
     	<div class="postfooter postinfo"><?php the_tags(__('Tags: '), ', ', ' — '); ?></div>
    
    <?php if (is_single()) : ?>
    <div class="footer"><hr /></div>
    <?php comments_template(); // Get wp-comments.php template ?>
    <?php endif; ?>
        <!-- end Entry --></div>
    
          <?php endwhile; else: ?>
    	<div class="entry">
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
        <!-- end Entry --></div>
    
    <?php endif; ?>
          <div class="footer"><hr /></div>
    
    <?php posts_nav_link(' — ', __('&laquo; Newer Posts'), __('Older Posts &raquo;')); ?>
          <!-- maincontent2 --></div>
    
            <div id="maincontent3">
          <h2 class="maintabs">
            <small><a href="javascript:void(0);" onclick="switch_main(1)">Sumo</a></small>
            <small><a href="javascript:void(0);" onclick="switch_main(2)">Articles</a></small>
            <big><b>SEO Tools</b></big>
            </h2>
    
      <div class="entry">
          <h1>Content 3 title</h1>
          <p>This page is under construction and it will be up soon.</p>
        <!-- end Content 3 --></div>
          <div class="footer"><hr /></div>
     <!-- end Content3 --></div>
    
     <!-- end mainContent --> </div>
    
    <?php include(TEMPLATEPATH.'/sidebars.php'); ?>
    
    <br class="clearfloat" />
    <!-- end #maincontainer --></div>
    
    <?php get_footer(); ?>

Viewing 7 replies - 91 through 97 (of 97 total)