Getting Blog Post to show on Front Page

Discussion in 'RoadFighter WordPress Theme' started by alclark2, Sep 15, 2013.

  1. alclark2

    alclark2 New Member

    Joined:
    May 9, 2013
    Messages:
    11
    Likes Received:
    0
    Hello,

    I have some blogs but they do not show up on the frontpage, is there a setting for the blog or setting for the front page I need to edit?

    Here is the link
    http://www.greengenes.net/
     
  2. Gourav

    Gourav Support Staff

    Joined:
    Oct 19, 2012
    Messages:
    7,728
    Likes Received:
    207
    Hello,

    Homepage shows the blog post of your theme that contain image, Create a post with an image, It will automatically display at your home page
     
  3. kevintje

    kevintje New Member

    Joined:
    Sep 16, 2013
    Messages:
    3
    Likes Received:
    0
    Hello,

    What change needs to be done to also show posts without image?
     
  4. Piyush

    Piyush Support Staff

    Joined:
    Dec 8, 2012
    Messages:
    4,745
    Likes Received:
    107
    Hello,
    Unfortunately there isn't a way to do that with our theme.
    You should create a post with an image, It will automatically display at your home page
     
  5. kevintje

    kevintje New Member

    Joined:
    Sep 16, 2013
    Messages:
    3
    Likes Received:
    0
    Hi,

    But I see in the code that it looks for posts that have an image.
    If a post has an images it gets displayed.

    So I assume this can be changed so that it searches all posts and not only posts that have an image?

    I tried removing this criteria but I get some errors, but i'm not a coder so I must be doing something wrong :)
     
  6. Piyush

    Piyush Support Staff

    Joined:
    Dec 8, 2012
    Messages:
    4,745
    Likes Received:
    107
    Hello,

    Go to the front-page.php file present in your theme directory and paste the code given below
    Code:
    <?php
                if (inkthemes_get_option('inkthemes_blog_post') != '')
                {
                $post_limit = stripslashes(inkthemes_get_option('inkthemes_blog_post'));
                } else {
                $post_limit = 3;
                }
                $args = array(
                'post_status' => 'publish',
                'posts_per_page' => $post_limit,
                'order' => 'DESC'
                );
                $query = new WP_Query($args);
                ?>
                <?php while ($query->have_posts()) : $query->the_post(); ?>

    In place of

    Code:
    <?php while (have_posts()) : the_post();   
                $content = $post->post_content;
                $searchimages = '~<img [^>]* />~';
                /*Run preg_match_all to grab all the images and save the results in $pics*/
                preg_match_all( $searchimages, $content, $pics );
                // Check to see if we have at least 1 image
                $iNumberOfPics = count($pics[0]);
                if (($iNumberOfPics > 0) || (has_post_thumbnail())){
                $key_1_value = get_post_meta( get_the_ID(), 'img_key', true );
                // check if the custom field has a value
                if( empty( $key_1_value ) ) {
                inkthemes_image_post($post->ID);
                }
                }
                endwhile; 
                ?>             
                <?php
                if (inkthemes_get_option('inkthemes_blog_post') != '')
                {
                $post_limit = stripslashes(inkthemes_get_option('inkthemes_blog_post'));
                } else {
                $post_limit = 3;
                }
                $args = array(
                'post_status' => 'publish',
                'posts_per_page' => $post_limit,
                'meta_key' => 'img_key',
                'meta_value' => 'on',
                'order' => 'DESC'
                );
                $query = new WP_Query($args);
                ?>
                <?php while ($query->have_posts()) : $query->the_post(); ?>
                <?php
                $content = $post->post_content;
                $searchimages = '~<img [^>]* />~';
                /*Run preg_match_all to grab all the images and save the results in $pics*/
                preg_match_all( $searchimages, $content, $pics );
                // Check to see if we have at least 1 image
                $iNumberOfPics = count($pics[0]);
                if (($iNumberOfPics > 0) || (has_post_thumbnail())){
            ?>

    See the link given below for the reference.
    http://screencast.com/t/q7x2HxuBY

    This will solve the issue.
     

Share This Page