-1

I'd like the first post on my home page (https://superchargeyour.blog) to be lengthier than the rest.

I also want to increase the excerpt length of each of the posts below. (include a few more words).

Both of these suggestions are inspired by this site: http://www.melyssagriffin.com/

Thank you so much :-)

0

It would help to include more information regarding the problem at hand. As well as explaining any progress you have made or attempted, and any particular areas you might have difficulty with. This will allow others to better help out with the problem.

What I have learned by inspecting the theme you are using is that it is child theme built off the genesis framework. As for increasing the excerpt length of each of the posts below the featured post, is possible with a setting in the dashboard under the genesis framework customization options in the wordpress admin dashboard:

enter image description here

For adding the featured post it is a bit complicated depending on your level of expertise. Note that I am not familiar with the genesis framework and am by no means an expert, just thought to lend a hand, hoping you might find this useful. please don't consider this to be a final solution, but perhaps useful for learning further on the topic as it was for me aswell.

"One" of the ways to achieve this would be to create a custom post loop, This will work in the case the featured post will always be the latest post, In order to not repeat the post again in the second loop, will be offset by 1. note the comments which give an idea to each section of the code. Paste this code at the bottom of your themes functions.php file.

//function to control excerpt word count for featured post

function feat_excerpt($limit) {
    $excerpt = explode(' ', get_the_excerpt(), $limit);
    if (count($excerpt) >= $limit) {
        array_pop($excerpt);
        $excerpt = implode(" ", $excerpt) . '...';
    } else {
        $excerpt = implode(" ", $excerpt);
    }
    $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt);
    return $excerpt;
}



//custom loop for featured post

function featured_custom_loop() {
    global $post;
    // arguments, adjust as needed
    $args = array(
        'post_type'      => 'post',
        'posts_per_page' => 1,
        'post_status'    => 'publish',
        'paged'          => get_query_var( 'paged' )
    );



    /* 
    Overwrite $wp_query with our new query.
    The only reason we're doing this is so the pagination functions work,
    since they use $wp_query. If pagination wasn't an issue, 
    use: https://gist.github.com/3218106
    */

    global $wp_query;
    $wp_query = new WP_Query( $args );
    if ( have_posts() ) : 
        echo '<div class="entry">';
        while ( have_posts() ) : the_post();

            echo '<h2 class="entry-title" style="" >' . get_the_title() . '</h2>';
            echo '<div class = "entry-meta" style="">'.genesis_post_info().'</div>';
            echo '<div class="entry-content" style=" word-wrap: break-word;">' . feat_excerpt(155) . '</div></br>' ;
            echo '<div style=""><a href="' . get_permalink() . '" class="more-link button arrow-right" >READ MORE</a></div></div>';
            endwhile;
        echo '</div>';

    endif;
    wp_reset_query();
}

///////////////////////// offset rest of the posts


function myprefix_query_offset(&$query) {




//Before anything else, make sure this is the right query...
if ( ! $query->is_main_query() ) {
    return;
}

$offset = 1 ;

//Next, determine how many posts per page you want (we'll use WordPress's settings)
$ppp = get_option('posts_per_page');

//Next, detect and handle pagination...
if ( $query->is_paged ) {

    //Manually determine page query offset (offset + current page (minus one) x posts per page)
    $page_offset = $offset + ( ($query->query_vars['paged']-1) * $ppp );

    //Apply adjust page offset
    $query->set('offset', $page_offset );

}
else {

    //This is the first page. Just use the offset...
    $query->set('offset',$offset);

}
}
add_action('pre_get_posts', 'myprefix_query_offset', 1 );

add_filter('found_posts', 'myprefix_adjust_offset_pagination', 1, 2 );

function myprefix_adjust_offset_pagination($found_posts, $query) {

    //Define our offset again...
    $offset = 1;

    //Ensure we're modifying the right query object...
    if ( $query->is_posts_page ) {
        //Reduce WordPress's found_posts count by the offset... 
        return $found_posts - $offset;
    }
    return $found_posts;
}

now to hook into the genesis_before_loop to load our custom featured_custom_loop. In your themes folder we you will find the front-page.php. In the section where you will find opening markup for the blog section look for where the line add_action( 'genesis_before_loop') is and add this line underneath:

add_action( 'genesis_before_loop', 'featured_custom_loop' );

Note that this is just meant to be an example but is far from an optimal solution, please take this example as a means to learn further. hoping a more experienced developer could add to this.

Note the Links below as they detail a similar process as to what you are trying to achieve:

sources:

www.steckinsights.com/offset-posts-genesis-framework-without-losing-pagination

http://genesisdictionary.com

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.