treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Vanishing posts on Wordpress page !?

  • Hello,

    I'm still a bit of a Wordpress novice and I've been setting this site up recently: http://graphicalchemy.co.uk/wordpressga2/

    It's a single page scrolling site and the blog section is supposed to appear in the designated "latest news " section/page.

    The blog posts do exist in the admin area and can be viewed as existing single posts from there – but no posts will show up on the actual wordpress page.

    (Strangely, when I was first creating the site locally on MAMP, it worked perfectly).

    Tried everything my limited knowledge will allow and it still doesn't seem to work. (including repairing the database on my host server). It seems to be a problem relating to the theme – but I don't know what.

    Is there anyone out there who could point me in the right direction to fixing this? I'd be most grateful for any help or advice.

    Thanks very much in advance...

    Kelpie.

  • Hi @Fossy

    Maybe try this;

    Log into the backend of your website and in the WordPress area go to Settings > Permalinks > Click the 'Save changes' button.

    If that doesn't work then make sure your posts are set as 'Published' and not set as a 'Draft'...

  • Hi Watson90,

    I gave this a try but no luck. It's a pretty unconventional theme and I think it has something to do with the php code – but I'm a complete nivice with php.

  • @Fossy

    So are your pages displaying correctly? It's just posts...

    You may have an error in your WordPress loop, can you copy and paste your index.php file code and put it in a comment on here, make sure to highlight it all and click the blue 'code' link above the textarea. It makes it easier to read through.

  •   <?php get_header(); ?>
    
      <?php get_template_part( 'include-left' ); ?>
    
    
    
    
      <div id="right">
    
    
    
    
        <!-- BEGIN: pages -->
        <?php 
    
          $pages = get_pages( 'sort_order=asc&sort_column=menu_order&depth=1' );
          foreach ( $pages as $pag ) {
            setup_postdata( $pag );
            $new_title = str_replace( " ", "", strtolower( $pag->post_name ) );
            echo '<div class="page" id="' . $new_title . '">';
              echo '<h2>';
              echo ( get_post_meta( $pag->ID, 'fdf_page_title', true ) ) ? get_post_meta( $pag->ID, 'fdf_page_title', true ) : $pag->post_title;
              echo '</h2>';
    
              $page_type = str_replace( ' ', '', strtolower( get_post_meta( $pag->ID, 'fdf_page_type', true ) ) );
              if ( $page_type == 'portfoliopage' ) {
                echo '<div id="portfolio-content" class="js-off-overflow">';
                echo '<ul id="page1" class="portfolio-thumbs js-off-position">';
                if ( get_post_meta( $pag->ID, 'fdf_portfolio_category', true ) != 'All' ) {
                  $portfolio_cat = get_post_meta( $pag->ID, 'fdf_portfolio_category', true );
                  $loop = new WP_Query( array( 'post_type' => 'portfolio_item', 'posts_per_page' => -1, 'tax_query' => array( array( 'taxonomy' => 'portfolio_category', 'field' => 'slug', 'terms' => $portfolio_cat ) ) ) );
                } else {
                  $loop = new WP_Query( array( 'post_type' => 'portfolio_item', 'posts_per_page' => -1 ) );
                }
                while ( $loop->have_posts() ) : $loop->the_post(); 
                  $thumb = get_post_thumbnail_id(); $image = fdf_resize( $thumb, '', 190, 190, true );
                  $item_name = str_replace( ' ', '', strtolower( $post->post_name ) ) ?>
                  <li>
                    <a href="#"><img src="<?php echo $image['url']; ?>" width="<?php echo $image['width']; ?>" height="<?php echo $image['height']; ?>" alt="<?php the_title_attribute(); ?>" /></a>
                    <div class="overlay">
                      <h5><?php the_title(); ?></h5>
                      <?php the_content(); ?>
                      <a class="zoom-btn" href="<?php echo get_post_meta( $post->ID, 'fdf_full_img_1', true ); ?>" rel="prettyPhoto[<?php echo $item_name; ?>]" title="<?php the_title_attribute(); ?>"></a>
                    </div>
                    <div class="extra_lightbox" style="display: none">
                      <?php
                        for ($i = 2; $i <= 5; $i++) {
                          if ( get_post_meta( $post->ID, 'fdf_full_img_' . $i, true ) ) { ?>
                            <a href="<?php echo get_post_meta( $post->ID, 'fdf_full_img_' . $i, true ); ?>" title="<?php the_title_attribute(); ?>" rel="prettyPhoto[<?php echo $item_name; ?>]"><?php the_title_attribute(); ?></a>
                          <?php }
                        }
    
                      ?>
                    </div>
                  </li>
                <?php endwhile;
                echo '</ul>';
                echo '</div>';
              } elseif ( $page_type == 'blogpage' ) {
                $loop = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $paged ) );
                echo '<div id="blog-page"><div id="ajax-container"><div id="ajax-inner">';
                while ( $loop->have_posts() ) : $loop->the_post(); ?>
                  <div class="blog-post">
                    <div class="post-title">
                      <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                      <div class="post-metadata">
                        <p><?php 
                          $post_categories = get_the_category();
                          $c = array_shift ( $post_categories );
                          $cats =  $c->cat_name;
                          if ( count( $post_categories ) > 0 ) {
                            foreach( $post_categories as $c ) {
                              $cats .=  ', ' . $c->cat_name;
                            }
                          }
                          printf( __( 'Posted on %1$s in %2$s with ', LANGUAGE ), get_the_time( 'F jS, Y' ), $cats );?>
                          <a href="<?php the_permalink(); ?>"><?php comments_number( '0 Comments', '1 Comment', '% Comments' ); ?></a>
                        </p>
                      </div>                
                    </div>
                    <div class="post-content">
                      <?php if ( has_post_thumbnail() ) the_post_thumbnail( 'full', array( 'class' => "image-left", ) ); ?>
                      <?php the_excerpt(); ?>
                      <a class="post-more-link" href="<?php the_permalink(); ?>"><?php _e ( 'Continue reading', LANGUAGE ); ?></a>
                    </div>
                  </div>
                  <div class="separator-line"></div>
                <?php endwhile; ?>
                <div id="posts-navigation"> 
                  <div class="alignleft"><?php next_posts_link( '&laquo; Older Entries', $loop->max_num_pages ) ?></div>
                  <div class="alignright"><?php previous_posts_link( 'Newer Entries &raquo;' ) ?></div>
                </div>
                <?php echo '</div></div></div>';
              } else {
                the_content();
              } 
            echo '</div>';
          }
        ?>
        <!-- END: pages -->
    
      </div>
      <?php wp_footer(); ?>
      </body>
      </html> 
    
  • The issue is "elseif ( $page_type == 'blogpage' )"

    Ignoring the loop, none of the html is showing up. Which mean the $page_type isn't matching. I can see near the top of the loop you use str_replace on the $page_type. Why do you do this? You're matching strings, you can have capital letters and spaces, it's ok. This only serves to screw things up.

    What I would test first is in the foreach loop, just echo out each $page_type value so you can see what values it's pulling from the database. You'll see why it's not matching your "blogpage" value. It's probably grabbing "blogpage1", or not getting any kind of "blogpage" value at all. Try that and report back with the results.

  • Thanks noahgelman,

    I appreciate your help very much but this is all a bit beyond my understanding of PHP right now. I do my best to understand but I'm a beginner in any kind of back end. The template is a very unusual arrangement in that it is a single page scrolling site with the blog section being on that same page.