WordPress.org

Ready to get started?Download WordPress

Forums

changing title from post id to post category (1 post)

  1. jordas
    Member
    Posted 2 years ago #

    Hi everyone,

    i have another riddle to solve. I have figured out a way to use 'get-the-image' to pick up images from my posts and am using a nice jquery script to have customized tooltips when people are mouse-overing over the image.

    The thing though is that I want to show the images post category instead of the post name. But get-the-image automatically assigns the post name to the <title> attribute. Now I know you can use this code `<?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?>` to echo the category name and I would like to hack it into the 'get the image' php file, but I am not a star at syntax.
    I've tried writing myself but I keep getting errors...

    It has to go in here:

    /* If $link_to_post is set to true, link the image to its post. */
    	if ( $link_to_post )
    		$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( apply_filters( 'the_title', get_post_field( 'post_title', $post_id ) ) ) . '">' . $html . '</a>';

    Anyone better at this? I think it must be quite simple...

    J

Topic Closed

This topic has been closed to new replies.

About this Topic