Link to users listing from listing id
This topic contains 12 replies, has 4 voices, and was last updated by Alex Howes 7 years, 7 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
May 26, 2018 at 3:10 pm #432276
Hello,
I’d like to add a link which goes to a user’s listing detail page, as part of a snippet. Is there a way to get the url by specifying the listing id?
Thanks,
AlexMay 26, 2018 at 5:42 pm #432293I don’t understand the question, I’m sorry, please try to explain it with more details and possibly an example.
Thanks
p.s. from the sound of it, this would be a customization
May 26, 2018 at 8:06 pm #432312Sorry, I’ll try to explain better.
One of my CPTs is CVs. I’m adding some extra information to a custom tab on the profile page as part of a snippet, to allow some users to view some other users’ CVs. I’ve written:
echo '<a href="url">View Worker CV</a>';where the url I’d like to go to is a user’s listing detail page. I have the listing id of the listing. Is this possible? I’m not sure how to get the url because the page is dynamic.
Thanks,
AlexMay 26, 2018 at 8:49 pm #432314May 27, 2018 at 9:55 am #432346Hi Alex, I don’t want to get the listing data, I want to get the url of the listing page.
Alex
May 28, 2018 at 5:41 pm #432488HI Alex,
I passed your question to the devs. They’ll let you know asap.
Sorry to keep you waiting, but being a customization this is has lower priority.
Thanks
May 28, 2018 at 6:10 pm #432495Thanks Paolo, no problem. Hope you’re enjoying memorial day 🙂
May 29, 2018 at 4:48 am #432527Hi Alex Howes,
Use following code snippet to get listing url from id.
function gd_cv_link( $atts = array(), $content = '' ) { $atts = shortcode_atts( array( 'id' => 0, ), $atts, 'gd_cv_link' ); if ( ! empty( $atts['id'] ) ) { $url = get_permalink( (int)$atts['id'] ); } else { $url = ''; } return $url; } add_shortcode( 'gd_cv_link', 'gd_cv_link' );Usage:
<a href="[gd_cv_link id="273"]">View Worker CV</a>replace 273 with id you want.
Kiran
May 29, 2018 at 9:30 am #432550Thanks for your response Kiran.
I’ve added it, but instead of the link going to the user’s CV, it reloads the same page but with [gd_cv_link%20id=cv_id]/ appended on the end of the url. Do you know what the problem might be?
Thanks,
AlexMay 29, 2018 at 9:32 am #432551Send your site admin link & admin credentials, i will take a look.
Kiran
May 29, 2018 at 4:01 pm #432617I’m writing it programmatically as part of a snippet. The snippet creates a new tab on the user’s profile and adds links to other users’ CVs. The $cv_id is a string containing the id of the listing, in this case ‘438’ (I’ve checked this). The tab and link are being created fine. When you click on the link, it reloads the page (the user’s account page) but with the url appended by /[gd_cv_link%20id=cv_id]/. I’ve also checked it using ‘438’ rather than $cv_id, but this doesn’t make a difference. The section of my code is:
$cv_url = gd_cv_link($cv_id); echo '<a href="[gd_cv_link id=$cv_id]">View Worker CV</a>';May 30, 2018 at 3:59 am #432677Hello,
Try this:
$cv_url = get_permalink( $cv_id ); echo '<a href="' . $cv_url . '">View Worker CV</a>';Kiran
May 30, 2018 at 9:46 am #432737Great, thanks! 🙂
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket