WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a plugin called leenk.me to post messages to Facebook based on my posts. One of the custom fields is %TITLE%, which posts the title of my post and the link to my post.

if ( false === $post_title )
    $post_title = get_the_title( $post_id );

The way I currently have my WP set up, my excerpt is a link. I want to modify the get_the_title function so that instead of getting the title and link (ID) to my post, it gets the title and the link to the excerpt.

function get_the_title( $post = 0 ) {
  $post = get_post( $post );

  $title = isset( $post->post_title ) ? $post->post_title : '';
  $id = isset( $post->ID) ? $post->ID : 0;

  if ( ! is_admin() ) {
    if ( ! empty( $post->post_password ) ) {
        $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) );
        $title = sprintf( $protected_title_format, $title );
    } else if ( isset( $post->post_status ) && 'private' == $post->post_status ) {
        $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) );
        $title = sprintf( $private_title_format, $title );

  return apply_filters( 'the_title', $title, $id );
share|improve this question
Can you elaborate on "link to the excerpt"? – TheDeadMedic Jun 22 '13 at 5:13

"I want to modify the get_the_title function" -- Do you mean you want to modify WordPress's get_the_title(), or simply modify what it returns? If the former, I must strongly advise against it. You shouldn't hack core files in WordPress. If you want to modify what it returns, use the the_title filter.

share|improve this answer
so should I change it to if ( false === $post_title ) $post_title = the_title( $post_id ); ? How can I change the_title to pull the_excerpt instead of the shortlink it normally grabs? – Anthony J. Arcuri Jun 22 '13 at 3:34
What does the relevant code from your leenk.me plugin look like? (Please add it to your question, since it can be formatted nicely in there.) – Pat J Jun 22 '13 at 15:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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