admin管理员组

文章数量:1406943

I want to pass the sub category id number from a post link <a href="<?php the_permalink() ?>"> is there any solution to pass the value from one page to another through link. we can pass the id as href=?id= and we can get value from at single post as a link will be www.example/post1/?id=22 Which will be dynamic link of a single post and I just need www.example/post1/ a single link and pass the value to single-post page is that possible.

I want to pass the sub category id number from a post link <a href="<?php the_permalink() ?>"> is there any solution to pass the value from one page to another through link. we can pass the id as href=?id= and we can get value from at single post as a link will be www.example/post1/?id=22 Which will be dynamic link of a single post and I just need www.example/post1/ a single link and pass the value to single-post page is that possible.

Share Improve this question edited Nov 26, 2019 at 15:13 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Nov 25, 2019 at 5:33 Roshan KhapungRoshan Khapung 13 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

the_permalink() only displays the URL for the current post in the loop. If you want to link to another post, you can use echo get_the_permalink( 123 );, where 123 is a post ID.

<a href="<?php echo get_the_permalink( 123 ) ?>">

Note that the_permalink() and get_the_permalink() only get URLs for posts. If you want to get the URL for a category (or tag, or other taxonomy term) you need to use get_term_link():

<a href="<?php echo get_term_link( 123 ) ?>">

本文标签: postsHow can we pass a value from thepermalink() at WordPress