Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • sorry..that code should have read:

    <?php get_header(); ?>
    <?php include(TEMPLATEPATH . '/loop.php'); ?>
    <?php get_sidebar(); ?>
    <div ID = "hidden"><?php include(TEMPLATEPATH . '/loop.php'); ?></div>
    <?php if(is_single() || is_page()) { comments_template(); } ?>
    <?php get_footer(); ?>

    no-one’s reading this dead topic anyway!

    This is a very ‘hacky’ workaround but nice & easy if, like me, php isn’t your strongest point.
    The problem is that the theme calls the loop, THEN the posts again for the ‘recent posts’ plugin widget. So the post that it thinks the comment relates to is the last processed by the widget instead of the loop (!!).
    My workaround runs the loop again, but invisibly. This probably causes a slightly longer load time, but nothing noticeable in my experience.

    Here’s the Main Index Template with the workaround. Replace everything in that file with this:

    <?php get_header(); ?>
    <?php include(TEMPLATEPATH . '/loop.php'); ?>
    <?php get_sidebar(); ?>
    
    <div ID = "hidden"><?php include(TEMPLATEPATH . '/loop.php'); ?></div>
    
    <?php if(is_single() || is_page()) { comments_template(); } ?>
    <?php get_footer(); ?>

    then add

    #hidden { display: none; }

    to the bottom of the style.css file.

    It’s clumsy, but easy. And it works! That way you can have recent posts & comments!

    now…if i can just workout how to get the comments form under the post instead of at the bottom of the sidebar it’ll be a perfect theme.

    Figured it out. It works great for the thumbnails.

    (Ignore the extra <a> in the strip_tags allow: I wanted these to link just to their larger images in lightbox. Remove that (so it reads

    <a href="<?php the_permalink (); ?>"<?php if ( get_the_excerpt() ) echo strip_tags(get_the_excerpt(),'<img>'); else the_ID(); ?> </a>

    for links to single posts.

    Here’s the code:

    <?php $r = new WP_Query('showposts=10');
    	if ($r->have_posts()) :
    ?>
              		<div class="portfoliocontent"
    			<?php  while ($r->have_posts()) : $r->the_post(); ?>
    			<a href="<?php the_permalink (); ?>"<?php if ( get_the_excerpt() ) echo strip_tags(get_the_excerpt(),'<img><a>'); else the_ID(); ?> </a>
    			<?php endwhile; ?>
                            </div>  
    
    <?php endif; ?>

    Thanks for your help doodlebee.
    ..and for your patience!

    Oops. Good spot, Doodlebee, thanks for that. It’s a cut & shove job so I know its very messy.
    Still figuring it out…

    So I’ve just digested & played around a bit….and what you’re suggesting before you answered my initial question seems to make sense & be very simple.
    Just set each div to the left, and make them 150 wide (my containing div being 450 wide), then they’ll start to go three posts wide.

    So, if I understand correctly, this would mean there’s no need for individual div IDs for the posts? Just set them all to the left, and they will fill the horizontal space until its full, then overlap to the next row?
    But that isn’t working for me. (big surprise!)

    Here’s the problem page (ignore the sidebar/footer probs)
    https://www.richard-wilkinson.com/category/portfolio/

    Here’s my loop for the portfolio page. (I’m dealing with thumnails in the_excerpt here btw. 95 px across, linking to lightbox instead of the post):

    <?php
    /*
    Template Name: Categories2
    */
    
    get_header(); ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="portfolioentry">
             <div class="blockcontent" id="blockcontent-<?php the_ID(); ?>">
    
             <a href="<?php the_permalink() ?>"><?php the_excerpt(); ?> </a>
             </div>
    <hr class="clear" />
    
    </div> <!-- closing post -->
    
    <hr class="clear" />
    
    <?php endwhile; ?>
    <?php endif; ?>

    and the relevant css:

    #blockcontent div {float:left; width:120px;}
    hr.clear {clear:both; visibility:hidden;}

    Any thoughts?

    Thanks again again!

    Doodlebee! I thanks my lucky stars you exist! I didn’t think this would be spotted – what luck!

    Trying it now..i’ll let you know.

    Thankyou so much.

    I know it’s 6 months later…but I found myself with the same problem.

    on https://www.richard-wilkinson.com

    I’m learning as I go so very slow progress (and probably very messy code!).

    I’m trying to make a portfolio page by creating an individual loop called category-5.php (when 5 = portfolio category ID)

    I can get the basic CSS to work (still struggling with sidebar/footer issues), but I’m struggling with the actual loop.

    Doodlebee – you were excellent in your solution last time, and it looks like you’ve maybe solved the problem again here. The problem is I dont totally understand the solution!

    Where, in your solution, it says ‘whatever the post code is here’…where do I find the code I’m after. It’s too baffling to get my head around, but I’m sure it’ll be obvious when I’m pointed in the right direction.

    Did anyone else have any success using this technique?
    I think it’s quite an important topic as it is SO useful for photoblogs/portfolios/galleries etc.

    Thanks.

    Thread Starter richardwilkinson

    (@richardwilkinson)

    Yoshi, thankyou so much!

    That was getting frustrating!

    Thanks Otto & Doodlebee too for all your help.

    Thread Starter richardwilkinson

    (@richardwilkinson)

    Thanks Otto, now I understand how strip tags works. So I understand how your workaround works.

    But…..!
    ..it’s still not working. It’s not outputting anything. I’ve tried

    <a href="<?php the_permalink(); ?>"><?php strip_tags(get_the_excerpt(),'<img>'); ?></a>
    
    and
    
    <a href="<?php the_permalink(); ?>"><?php strip_tags(get_the_excerpt(),'<src>'); ?></a>

    ..still no luck.
    Any ideas?

    Thread Starter richardwilkinson

    (@richardwilkinson)

    Thanks Doodlebee. Yes, that’s starting to make sense.

    I’m looking into Otto’s answer but to be honest I’m having to learn very fast!!

    Strip Tags remove HTML from the excerpt, right? So, why wont that remove my image and just leave me with the text (of which there is none!!)

    I’m still reading about strip tags….can’t find a list of the parameters yet.

    Thread Starter richardwilkinson

    (@richardwilkinson)

    Thanks Otto, that makes a lot of sense!

    I’ve tried your code in place of mine (I guessed that’s what you meant), but now its not showing anything…no thumbnails.

    What am I doing wrong?

    I’m going to read up on strip_tags now!!

    Thanks again for your help.

    Thread Starter richardwilkinson

    (@richardwilkinson)

    the code now is:

    <a href="<?php the_permalink(); ?>"><?php the_excerpt(); ?></a>

    ..the result is that the thumbnail does have a link (i.e. the cursor changes when hover, as it did when the code was wrong, actually!) but when I click it it links to the thumbnail URL instead of the post.

    Thread Starter richardwilkinson

    (@richardwilkinson)

    Thanks for that. I’ve swapped it round & now it links to the large image (direct link just to the image, not to the post), which is better, but still a problem.

    Any ideas?

    As I said, I’m just learning as I go, adapting a theme, so excuse my ignorance!

Viewing 13 replies - 1 through 13 (of 13 total)