WP get_permalink Return Wrong URL

Question

I have custom post type named: easytask, and the following code is shortcode from plugin to retrieve data from the custom post above ( easytask ).

function easy_shortcode( $attr ) {

    // Shortcode parameter
    extract( shortcode_atts( array(
        'med' => -1,
        ), $attr ) );

    $easy_id = explode( ",", $med );

    // Get data from custom post type
    $easy_arg = array(
        'post__in' => $easy_id, 
        'post_type' => 'easytask',
    );

    $easy_query = new WP_Query( $easy_arg );

    if ( $easy_query->have_posts() ):

        while ( $easy_query->have_posts() ) : $easy_query->the_post();

            // Content from our custom Post goes here...

        endwhile;
        wp_reset_postdata();

    else:

        // If empty

    endif;

}

add_shortcode( 'easy-task', 'easy_shortcode' );

But when I put the shortcode into the blog list, the theme function that uses get_permalink return the wrong URL, in this case, the URL should be the return to the post URL itself, but my issue is the URL return the custom post URL.

NOTE:
All posts in blog list have the correct link except the post that containing the easy-task shortcode.

The following code is the theme function I found in theme functions.php that conflict with the easy-task shortcode.

function adventure_posted_on() {

            printf( __( '<span class="%1$s">Last Updated:</span> %2$s <span class="meta-sep">by</span> %3$s', 'organic-adventure' ),
                'meta-prep meta-prep-author',
                sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a>',
                    esc_url( get_permalink() ),
                    esc_attr( get_the_modified_time() ),
                    get_the_modified_date()
                ),
                sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s">%3$s</a></span>',
                    esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
                    sprintf( esc_attr__( 'View all posts by %s', 'organic-adventure' ), get_the_author() ),
                    get_the_author()
                )
            );
}

Can anyone help me with this?

0
, , , Peter Chimp 4 years 2020-02-21T08:39:09-05:00 0 Answers 117 views 0

Leave an answer

Browse
Browse