WordPress.org

Support

Support » Plugins and Hacks » Hacks » custom static front page with posts

custom static front page with posts

  • Hi all I really need some help here. Can anybody direct me in the right direction?
    I would be really grateful the problem I am having is the following;

    I have a static front page on which I would like to have one area where I just have two columns with specific posts which is working.For this to work I have made a template with the code but the problem is that it will not post on the page but just below with other posts which are normally visible on the front page. How can this be avoided? I have been offered the solution to delete the code in page.php but then I lose the posts which normally would be filling the page so that is not really an option.

    So to be clear I would like to have the following set up for my page:

    Header – slider – custom posts – posts .

    Many thanks in advance

    <? /* Template Name: news */ ?>
        <?php
        /**
     * Template for news on the front page
     */
    
    get_header(); ?>
    
        <?php
        /* Run the loop to output the pages.
         * If you want to overload this in a child theme then include a file
         * called loop-page.php and that will be used instead.
        */
        the_post();
        get_template_part( 'loop', 'page' );
       ?>
    <div style="float:left;width:50%;">
    <div style="padding-right:5px;">
    LEFT CONTENT HERE
    
    <?php
    global $more;
    $more = 0;
    query_posts('cat=58&posts_per_page=1');
    if(have_posts()) :
    while(have_posts()) :the_post();
    ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2>
    <div><?php the_excerpt(); ?></div>
    <?php
    endwhile;
    endif;
    wp_reset_query();?>
    </div></div>
    <div style="float:right;width:50%;">
    <div style="padding-left:5px;">
    LEFT CONTENT HERE
Viewing 2 replies - 1 through 2 (of 2 total)
  • To get your post type, you can use

    $custom_query = new WP_Query(array(
            'post_status' => 'publish',
            'post_type' => 'post',  /* <----- replace with your post type */
            'order' => 'ASC',
            'order_by' => 'ID',
            'posts_per_page' => '2',
        ));
    
    http://codex.wordpress.org/Class_Reference/WP_Query

    That did not work but I found away thanks for your help though 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘custom static front page with posts’ is closed to new replies.
Skip to toolbar