Welcome to PressWork!

Want to ask a question or join the discussion? Great! Join now.

In this Discussion

Featured Image
  • In version 1.0 of Presswork is it possible to have the featured image of the latest post not appear as a big image on top but as an smaller image on the left of the post like other posts ?
  • By default, the first post will display the featured image at full width. That is a design choice. The easiest way to fix that would be to open up /admin/actions.php and edit this:
    296
    297
    298
    299
    300
    301
    302
    if(function_exists('has_post_thumbnail') && has_post_thumbnail()) { 
    echo '<a href="'.get_permalink().'">';
    if($pw==1) { $thumb = 'sticky'; $class = 'alignnone'; } else { $thumb = 'thumbnail'; $class = 'alignleft'; }
    the_post_thumbnail($thumb, array('class'=>$class));
    echo '</a>';
    $rightcon = ' class="content-col"';
    }


    So that it looks like this:
    296
    297
    298
    299
    300
    301
    302
    if(function_exists('has_post_thumbnail') && has_post_thumbnail()) { 
    echo '<a href="'.get_permalink().'">';
    $thumb = 'thumbnail'; $class = 'alignleft';
    the_post_thumbnail($thumb, array('class'=>$class));
    echo '</a>';
    $rightcon = ' class="content-col"';
    }


    The best and safest way to do this using the advanced developer tools for PW would be to create a file called custom-actions.php in your uploads folder and add this to it:
    <?php
    remove_action('pw_index_featured_post_middle', 'pw_posts_featured');
    add_action('pw_index_featured_post_middle', 'pw_new_posts_featured');
    function pw_new_posts_featured() {
    echo pw_function_handle(__FUNCTION__);
    global $pw;
    $rightcon = '';
    if(function_exists('has_post_thumbnail') && has_post_thumbnail()) {
    echo '<a href="'.get_permalink().'">';
    $thumb = 'thumbnail'; $class = 'alignleft';
    the_post_thumbnail($thumb, array('class'=>$class));
    echo '</a>';
    $rightcon = ' class="content-col"';
    }
    ?>
    <div<?php echo $rightcon; ?>>
    <header>
    <hgroup>
    <h1 class="posttitle"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', "presswork" ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    <h2 class="meta">
    <?php
    _e("by", "presswork"); echo " "; the_author_posts_link();
    echo '&nbsp;&bull;&nbsp;';
    the_time(get_option('date_format'));
    if(comments_open()) { echo '&nbsp;&bull;&nbsp;'; comments_popup_link(__('0 Comments', "presswork"),__('1 Comment', "presswork"),__('% Comments', "presswork")); }
    ?>
    </h2>
    </hgroup>
    </header>
    <div class="storycontent">
    <?php
    if(function_exists('has_post_format') &&
    (has_post_format('aside') || has_post_format('link') || has_post_format('video') || has_post_format('image') || has_post_format('audio'))) {
    // new aside || link || audio || video || image post format
    echo '<div class="pformat clear">';
    the_content('');
    echo '</div>';
    } elseif(function_exists('has_post_format') && has_post_format('gallery')) { // new gallery post format
    global $post;
    $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => 999 ) );
    if ( $images ) :
    $total_images = count( $images );
    $image = array_shift( $images );
    $image_img_tag = wp_get_attachment_image( $image->ID, 'full' );
    ?>
    <a class="gallery-thumb" href="<?php the_permalink(); ?>"><?php echo $image_img_tag; ?></a>
    <p class="gallery-text clear fl"><em><?php printf( _n( 'This gallery contains <a %1$s>%2$s photo &rarr;</a>.', 'This gallery contains <a %1$s>%2$s photos &rarr;</a>.', $total_images, "presswork" ),
    'href="' . get_permalink() . '" title="' . sprintf( esc_attr__( 'Permalink to %s', "presswork" ), the_title_attribute( 'echo=0' ) ) . '" rel="bookmark"',
    number_format_i18n( $total_images )
    ); ?></em>
    </p>
    <?php endif; ?>
    <?php
    } else {
    the_excerpt();
    echo '<a href="'.get_permalink().'" class="more-link">'.__("Read more &rarr;", "presswork").'</a>';
    ?>
    <?php } ?>
    </div>
    </div>
    <?php
    }


    Adding it this way will protect you from losing your changes when you update the theme. You could also just create a child theme and add an actions.php file with the above code.
    Post edited by cbavota at 2011-08-24 15:14:54
    image Senior Developer & Co-Founder of PressWork
  • I created a custom-actions.php file with the above code and put it in my uploads folder and it is not working. I am still getting the large featured post first. I noticed when I copy the above code as is, I get a syntax error in dreamweaver is there any code missing?
  • Make sure that you include an opening PHP tag.
    image Senior Developer & Co-Founder of PressWork
  • Hey there!
    I tried to use this code by myself. Code was ok, but it also didn't work. The only change was, that the picture of the first featured post was stretched in height! Looks even worse. It looks like the align-left isn't accepted! Any ideas?
    Post edited by Bongokarl at 2011-08-26 07:41:42
  • I discovered the issue. It has been fixed for 1.0.3 which is awaiting approval on WordPress.org.

    You also need to use this:
    remove_action('pw_home_page', 'pw_home_page_featured_query');
    add_action('pw_home_page', 'new_pw_home_page_featured_query');
    function new_pw_home_page_featured_query() {
    global $post, $notin, $paged, $pw;
    $pw = '';
    $sticky = get_option( 'sticky_posts' );
    $notin = pw_notin();
    if(!empty($sticky)) {
    if(!empty($notin)) $notin = array_merge($notin, $sticky); else $notin = $sticky;
    if($paged < 2) {
    $args = array(
    'post__in' => $sticky,
    'ignore_sticky_posts' => 1
    );
    $the_query = new WP_Query( $args );
    while ( $the_query->have_posts() ) : $the_query->the_post();
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class("pw"); ?>>
    <?php pw_actionBlock('pw_index_sticky_post'); ?>
    </article>
    <?php
    endwhile;
    wp_reset_query();
    }
    } else {
    $args = array(
    'post__not_in' => $notin,
    'posts_per_page' => 2
    );
    $the_query = new WP_Query( $args );
    while ( $the_query->have_posts() ) : $the_query->the_post();
    if($paged < 2) {
    $notin[] = $post->ID;
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class("pw"); ?>>
    <?php pw_actionBlock('pw_index_featured_post'); ?>
    </article>
    <?php
    } else {
    $notin[] = $post->ID;
    }
    endwhile;
    wp_reset_query();
    }
    query_posts( array( 'post__not_in' => $notin, "paged" => $paged ) );
    }
    Post edited by cbavota at 2011-08-26 11:35:41
    image Senior Developer & Co-Founder of PressWork
  • THANK YOU!!!!!!!
  • Hello!! Are these steps ok for 1.0.4.2 as I can`t get this to work. Tried to change the code (there were some differences) and I got an error and restored the original actions.php. Tried custom-actions.php in uploads folder, but no change in the size of the image