我有名为的自定义帖子类型:easytask, 下面的代码是插件的短代码,用于从上面的自定义帖子中检索数据(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\' );
但是,当我将短代码放入博客列表时,使用get\\u permalink的主题函数返回了错误的URL,在这种情况下,URL应该返回到帖子URL本身,但我的问题是URL返回自定义帖子URL。
注:All posts in blog list have the correct link except the post that containing the easy-task shortcode.
下面的代码是我在theme中找到的theme函数functions.php 这与easy task短代码冲突。
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()
)
);
}
有人能帮我吗?