Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter malus

    (@malus)

    Still not solved!

    Thread Starter malus

    (@malus)

    How can i make this works then?
    Is there another way to set a pagination without global?

    This is really important :s

    Thread Starter malus

    (@malus)

    Ok so how can i force the global to load after my template ?

    Thread Starter malus

    (@malus)

    I would really appreciate some help!

    – I tryed to remove my pagination function and access manually to the last page but still get the error
    – I removed each loop from my index.php but one, still get the error;
    – I changed the last loop left to a standard one with wp_query, still get the error;
    – My module-rewite is correctly enable and nothing change when i change my permalink (i mean i still get the error in any cases);

    I don’t really know what i can do to test this kind of stuff..

    Im desperate 🙁

    Thread Starter malus

    (@malus)

    Nobody can help? 🙂

    Thread Starter malus

    (@malus)

    Any idea? 🙁

    Thread Starter malus

    (@malus)

    I don’t know what i can do to test anything.. This works fine when i don’t have the template page 404.php …

    Thread Starter malus

    (@malus)

    Yes!
    That’s working perfectly!

    Thanks a lot!

    Thread Starter malus

    (@malus)

    $cat_args = array(
            'child_of'      => 0,
            'orderby'       => 'name',
            'order'         => 'ASC',
            'hide_empty'    => 1,
            'taxonomy'      => 'category'
        );
        $cats = get_categories($cat_args);
    
        $sticky = get_option('sticky_posts');
        foreach ($cats as $cat) :
            $args = array(
                'post_type'         => 'post',
                'post__in'          => $sticky
                'posts_per_page'    => -1,
                'orderby'           => 'title',  // or whatever you want
                'tax_query' => array(
                    array(
                        'taxonomy'  => 'category',
                        'field'     => 'slug',
                        'terms'     => $cat->slug
                    )
                )
            );
            $posts = get_posts($args);
            if ($posts) :
            ?>
    
              <div class="flex-6">
              <h4><?php echo $cat->cat_name; ?></h4>
              <ul class="list">
                <?php foreach ($posts as $post) : ?>
                <li><a href="<?php echo get_permalink($post->ID); ?>"><?php echo get_the_title($post->ID); ?></a></li>
                <?php endforeach; ?>
            </ul>
            </div>
            <?php
            endif;
        endforeach;

    Maybe there is a better way to do this?
    This will check the categories and for each categories look at the sticky post in there and display the post under their category like this:

    <div class="flex-6">
      <h4>The first categorie title</h4>
      <ul class="list">
        <li><a href="#">The name of the post 1</a></li>
        <li><a href="#">The name of the post 3</a></li>
        <li><a href="#">The name of the post 5</a></li>
      </ul>
    </div>
    <div class="flex-6">
      <h4>The second categorie title</h4>
      <ul class="list">
        <li><a href="#">The name of the post 2</a></li>
        <li><a href="#">The name of the post 4</a></li>
        <li><a href="#">The name of the post 6</a></li>
      </ul>
    </div>
    Thread Starter malus

    (@malus)

    That does nothing 🙁

    Thread Starter malus

    (@malus)

    without the ‘else’ code, this will always be shown: <p><?php _e( ‘Sorry, no posts matched your criteria.’ ); ?></p> even if there are posts.

    Yes i understand but that not breaking anything isn’t it? It shows only something everytime. (i will fix that)

    do you actually get any post output before the error message?

    Nope that’s the point, i get only the static html code inside my loop. So the wp code like the_title, the_content or the related posts and the comment are not displayed.

    Thread Starter malus

    (@malus)

    Thanks for your answer!

    Ok so this is the single.php code:

    <?php get_header(); ?>
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
        <div id="single">
          <div class="flex inner">
            <section class="flex-9 flex single">
             <div class="container">
              <header class="flex-12 flex align-center">
                <div class="flex-2 prev ovh" data-load="single">
                  <?php
                    $nextPost = get_next_post();
                    $nextThumbnail = get_the_post_thumbnail( $nextPost->ID, 'thumbnail_widget' );
                    next_post_link( '%link', $nextThumbnail );
                  ?>
    
                </div>
                <div class="flex-8 center ruban">
                  <h1><?php the_title(); ?></h1>
                <div class="flex-2 next ovh" data-load="single">
                  <?php
                    $prevPost = get_previous_post();
                    $prevThumbnail = get_the_post_thumbnail( $prevPost->ID, 'thumbnail_widget' );
                    previous_post_link( '%link', $prevThumbnail );
                  ?>
                </div>
              </header>
              <article class="flex-12 center">
                <?php the_post_thumbnail(); ?>
                <div class="content text-left">
                  <?php the_content();    ?>
                </div>
              </article>
              </div>
            </section>       
    
            <section class="related flex-12">
              <div class="flex">
                <?php
                 $orig_post = $post;
                 global $post;
                 $tags = wp_get_post_tags($post->ID);
    
                 if ($tags) {
                   $tag_ids = array();
                   foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
                   $args=array(
                     'tag__in' => $tag_ids,
                     'post__not_in' => array($post->ID),
                     'posts_per_page'=>6, // Number of related posts to display.
                     'caller_get_posts'=>1
                   );
    
                   $my_query = new wp_query( $args );
    
                   while( $my_query->have_posts() ) {
                    $my_query->the_post();
                   ?>
    
                    <a class="flex-2 box-shadow" href="<?php the_permalink()?>"><?php the_post_thumbnail(); ?><br />
                    <h6><?php the_title(); ?></h6>
                    </a>
    
                   <?php }
                 }
                 $post = $orig_post;
                 wp_reset_query();
                 ?>
              </div>
            </section>
    
            <div class="comments flex-12">
             <?php
               if ( comments_open() || get_comments_number() ) :
                comments_template();
               endif;
              ?>
            </div>
          </div>
    
    <?php endwhile; ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
    <?php get_footer(); ?>

    This is what header contains:

    <nav>
            <?php
    
              $defaults = array(
               'container'       =>  false,
               'menu_class'      => 'center db-border main-menu inline inline-list',
               'echo'            => true,
               'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>',
               'depth'           => 0,
               'walker'          => ''
              );
    
              wp_nav_menu( $defaults );
    
            ?> 
    
            <div class="sub-menu ovh" id="recette-hover">
             <?php include('liste-recette-template.php'); ?>
            </div>
          </nav>
        </header>
    
        <div class="call-to-action">
          <ul>
            <li><a href="#"><div class="discover">Découverte</div></a></li>
            <li><a href="#"><div class="recette-une">Recette à la une</div></a></li>
            <li><a href="#"><div class="recette-alea">Recette aléatoire</div></a></li>
          </ul>
        </div>

    And the “liste-recette-template” contains is the code i provide earlier.
    Why whould i need a else part if there is nothing else? (maybe for the error message but i will remove it i guess.

    Thread Starter malus

    (@malus)

    Am i in the right section? 🙂

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