0

I have a custom grid loop to show a specific post type on a page.

This shows the excertp for each post but it does not link include the post title, and I would like each post to have a title that links to the full post. Can anyone help?

thanks,

<?php
/**
  * @author Jonathan Perez
 */

/*
Template Name: Grid Loop for Press Releases
*/

// Do the Custom Loop
remove_action('genesis_loop', 'genesis_do_loop');
add_action( 'genesis_loop', 'sf_custom_loop' );

function sf_custom_loop() {


        echo '<h3 class="entry-title media-title">' . get_the_title() . '</h3>';
        the_content();

        //WP Query Start

        $per_page = 9;

        $product_args = array(
            'post_type' => 'pressreleases',
            'posts_per_page' => $per_page,
                            'paged' => get_query_var( 'paged' )
        );
        $products = genesis_custom_loop( $product_args );
}

//Add Post Class Filter
add_filter('post_class', 'sf_post_class');
function sf_post_class($classes) {
    global $loop_counter;
    if ($loop_counter % 3 == 0) {
        $classes[] .= 'first ';
    }
    return $classes;
}



/** Move Post Info */
remove_action('genesis_before_post_content','genesis_post_info');
remove_action('genesis_after_post_content','genesis_post_meta');

genesis();
  • Your code displays the Post Title here: echo '<h3 class="entry-title media-title">' . get_the_title() . '</h3>';. Is the issue the need to display the title, or that you want to wrap the title in a Permalink? Also, you say that the code displays the excerpt, yet you call the_content() in the code. Are you sure you've pasted the correct code? – Chip Bennett Nov 25 '13 at 13:08
  • Thanks Chip. Yes I would like to wrap the title in a link. So far I have had to add these titles in h5 tags manually in the post (hope that makes sense). – Oliver Nov 25 '13 at 14:01
  • kube.co.uk/genesis2013/?page_id=34 – Oliver Nov 25 '13 at 14:03
1

If you just want to wrap the post title in a permalink, change this:

echo '<h3 class="entry-title media-title">' . get_the_title() . '</h3>';

...to this:

echo '<a href="' . get_permalink() . '"><h3 class="entry-title media-title">' . get_the_title() . '</h3></a>';

Codex reference: get_permalink()

  • I think the above link only applies to the page title (press releases) which I do not want to change. Just to clarify, this is an archive page which draws in the 'press releases' post type. At present this is working fine but it does not show the post title. so I am having to manually write this in the excerpt section of the post. However I would like to automatically include the post title in the excerpt for each post, linking to the full post. – Oliver Nov 25 '13 at 15:50
  • Well, if that's the case, then you'll need to look at the output of, I'm guessing, genesis_custom_loop( $product_args ); - but for that, you'll need StudioPress support, as Genesis is a commercial Theme. – Chip Bennett Nov 25 '13 at 15:57

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