• Hello,

    since a few weeks i have a problem with the permalink after the excerpt!
    The permalinks above the excerpt-code works fine!!!

    the permalink returns the current page’s permalink and not the excerpt’s permalink.

    The Code in my function.php looks like this:

    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink(2668) . '">' . __( '<img class="weiterlesen" align="right" width="48" height="32" alt=""',  'twentyten' ) . '</a>';
    }

    Now, everytime i make a new post, i have to write the right post-id in get_permalink()

    Thanks!!

Viewing 14 replies - 1 through 14 (of 14 total)
  • Are you using a child theme?

    Thread Starter moedeboum

    (@moedeboum)

    No, i created my own theme.
    But i used the twenty-ten as basis

    Thread Starter moedeboum

    (@moedeboum)

    The first months it worked fine.
    My problem: I dont now what caused the “function-crash”

    How are you calling this function?

    Thread Starter moedeboum

    (@moedeboum)

    Do u mean in my Template?

    I use this code:
    <?php the_excerpt(); ?>

    And the continue_reading button is created by the function twentyten_continue_reading_link() in my function.php

    the continue_reading button is created by the function twentyten_continue_reading_link() in my function.php

    How? I see no add_hook or add_filter in the code you posted above.

    Thread Starter moedeboum

    (@moedeboum)

    There never has been a filter.

    This is the code of the original Twenty-Ten Theme:

    /**
     * Returns a "Continue Reading" link for excerpts
     *
     * @since Twenty Ten 1.0
     * @return string "Continue Reading" link
     */
    function twentyten_continue_reading_link() {
    	return ' <a href="'. get_permalink() . '">' . __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) . '</a>';
    }

    That’s because it is called using a second function:

    function twentyten_auto_excerpt_more( $more ) {
    	return ' &hellip;' . twentyten_continue_reading_link();
    }
    add_filter( 'excerpt_more', 'twentyten_auto_excerpt_more' );
    Thread Starter moedeboum

    (@moedeboum)

    I also use this function!

    the permalink returns the current page’s permalink and not the excerpt’s permalink.

    are you using a page template?

    if yes, what is the full code of that template?

    Thread Starter moedeboum

    (@moedeboum)

    This is the Code of the Page:

    <?php
    	/**
    	 * Template Name: Home-2
    	 * A custom page template forthe Home-2-Page.
    	 */
    get_header(); ?>
    
    <div id="content">
     <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
      <div id="intro-text-home">
       <?php the_content(); ?>
       <?php endwhile; ?>
      </div>
      <!--intro-text-->
     <div id="blog-intro-home"><!--blog-header-->
      <div id="blog-article-home">
        <?php $args = array( 'numberposts' => 1, 'order'=> 'DESC', 'orderby' => 'post_date' ); $postslist = get_posts( $args ); foreach ($postslist as $post) :  setup_postdata($post); ?>
        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
        <?php the_date('d', '<span class="day">', '</span>'); ?>
        <span class="month"><?php the_time('M'); ?></span>
        <span class="author">gepostet von <?php the_author(); ?></span>
        <br />
        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail (thumbnail); ?></a>
        <br /><br />
        <?php the_excerpt(); ?>
      </div>
      <!--blog-article-->
     </div>
     <!--blog-intro-->
    
    <?php endforeach; ?>
    
    <?php get_footer(); ?> 
    
    </div>
    <!--end content-->

    you could try:

    <a href="<?php echo get_permalink($post->ID); ?>">..........

    Thread Starter moedeboum

    (@moedeboum)

    It doesnt work!

    It is so weird: every permalink above the <?php the_excerpt(); ?> works fine, but if i put the permalink below the <?php the_excerpt(); ?> it doesnt work!!

    the permalink returns the current page’s permalink

    do your excerpts have a ‘read-more’ link at the end?
    i.e. does your theme have any filters for instance on ‘excerpt_more’ ?

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘get_permalink returning wrong link in excerpt’ is closed to new replies.