Forum Replies Created

Viewing 7 replies - 61 through 67 (of 67 total)
  • Thread Starter soeezauto

    (@soeezauto)

    Just to mark the issue as resolved.

    Thread Starter soeezauto

    (@soeezauto)

    Hello karpstrucking, thanks for your reply.

    In the meantime I was pursuing another ways to do this and found a tip
    at StackOverflow (lost the link since them ).

    I actually did not try your method, but it seems in line with what I found in the end.

    So, I put the post ID’s from the first loop in an array and then, in the second loop, just skipped the posts whose ID were on the ID array.

    Thanks again!

    <?php
    $tag = $brand;
    
        $args=array(
          'tag' => $tag,
          'showposts'=>5
        );
        $my_query = new WP_Query($args);
    $id=array();
        if( $my_query->have_posts() ) {
          echo '<h2>Articles liés à '.$tag.':</h2>';
    $nct = $my_query->post_count;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <div class="news_call">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h3><?php the_title(); ?></h3></a>
    
    	<div class="storycontent">
    		<?php the_content(__('(lire la suite...)')); ?>
    	</div>
    </div>
    <?php
    $ids[]= $post->ID;//**** GOT THE ID's HERE****
          endwhile;
        }
    if((!isset($nct) or $nct < 5)){
    (isset($nct) ? $n_posts = 6-$nct : $n_posts=5);
    	global $post;
    $args = array( 'posts_per_page' => $n_posts,
    	       );
        $my_query = new WP_Query($args);
         if( $my_query->have_posts() ) {
          echo '<h2>Articles récents:</h2>';
    
          while ($my_query->have_posts()) : $my_query->the_post();
         if ( !isset($ids) or !in_array($post->ID, $ids)){ //*** EXCLUDED POSTS WITH ID SAME AS IN ID ARRAY****
          ?>
    <div class="news_call">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h3><?php the_title(); ?></h3></a>
    
    	<div class="storycontent">
    		<?php the_content(__('(lire la suite...)')); ?>
    	</div>
    </div>
    <?php }endwhile;
    }
        }
      wp_reset_query();  // Restore global post data stomped by the_post().
    
    ?>

    Hello

    I am quite new to WP and may be my solution isn’t the best, but seems to work for me. It requires some basic knowledge of HTML/CSS.

    Also, I am integrating WP to my site, no full site installation, but that does not change much the procedure, I believe.

    Before the regular post contents and media, I added the teaser images to the post in post editing.

    Using the text view, I added a html <div> tag around the image and gave it a class name.

    I set the [more] tag where I need it.

    Then, on the loop placed on the page where I want to show the teaser, short version, excerpt, whatever you call it, I set it to content, not excerpt.

    Then, with CSS display property in your regular style sheet you can control whether or not that image shows, by setting it to display:none or allowing it its default, ie, it shows.

    That’s it. In my case I have 2 different places with different sizes where I want to show the teasers, so I actually added 2 images to the post, that are shown each at the desired place.

    It is not set up with WP, yet, but the result will be as you see at the homepage/blog page and posts at http://www.soeezauto.ma.

    Hope that helps.

    Thread Starter soeezauto

    (@soeezauto)

    I seem to have found the problem,which was the loop above.

    I have replaced with the one below ( copied/pasted from some part of the Codex) already with some customization to show desired set up for my homepage.

    <div class="blog_call">
     <?php
    global $post;
    $args = array( 'posts_per_page' => 3 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <div class="news_call">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><h3><?php the_title(); ?></h3></a>
    
    	<div class="storycontent">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    </div>
    <?php endforeach; ?>  
    
    </div>

    Thread Starter soeezauto

    (@soeezauto)

    I took a while to confirm.

    No, there are no other WP loops.

    I noticed the following when trying to give you a proper response:
    if I start from the WP page (localhost/blog/) and click the article it will show at index.php or at my other page blog-main.php, depending upon what I put on .htaccess.

    But, when I try to open index.php/blog-main.php from any other navigation button, it will give me the dreaded message ( sorry no posts correspond to your criteria)

    Thread Starter soeezauto

    (@soeezauto)

    Ok,

    on my homepage, index.php:
    first thing on top ( ok, second actually, there is mod_rewrite stuff that should come first):

    <?php
    require('./blog/wp-blog-header.php');
    ?>

    then on my right column I created a division class blog_call, like below, which does show the excerpts or contents, whatever I choose.
    Always very much in line with what you see on my web site today.

    Exactly the same set up was repeated on my blog page, only that THE LOOP goes into another division, the main content.

    Thing is, at this page, the article/excerpt does not show. I get the message ‘no posts match your criteria’. As the loops are identical I was expecting to see the same result in both pages.

    I was under the impression that I could replicate the article/excerpt at will, per the setup I explained on my orginal post.

    Thanks for your assistance

    <div class="blog_call"> 
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php the_date('','<h2>','</h2>'); ?>
    
    <div class="post" id="post-<?php the_ID(); ?>" >
    	 <h3 class="storytitle"><a>" rel="bookmark"><?php the_title(); ?></a></h3>
    	<div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    
    	<div class="storycontent">
    		<?php the_excerpt(__('(more...)')); ?>
    	</div>
    
    	<div class="feedback">
                <?php wp_link_pages(); ?>
                <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    	</div>
    
    </div>
    
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    </div>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    Thread Starter soeezauto

    (@soeezauto)

    Thanks, esmi.

    I did try that. Problem is that it posts the article(content) or the excerpt, depending on what I put into THE LOOP, to index.php or other page defined in .htaccess, it seems, not to another page which also has THE LOOP.

    I put THE LOOP in another page to test and got the message that there was nothing to post according to my criteria, which is the same in both loops.

    Also, does not seem to give me the possibility to adjust the media, images in the case, to be different depending upon the page where the article/excerpt is shown.

    I just might be missing something there.

Viewing 7 replies - 61 through 67 (of 67 total)