Home Forums Front-end Issues Get fields from a clicked link


Get fields from a clicked link

  • I have a list of posts.

    When I click on a post, I want a modal window to appear, containing three fields from that post.

    The thing is, I don’t know how to get the post ID that I clicked on into the PHP code to tell it where to get those fields from.

    Can anyone help?

  • Hi there,

    Wordpress has a built-in function to determine the post ID from a given URL : url_to_postid( string $url );
    It will return the post ID or 0 on failure.

    1) So first, you’ll probably target your clicked url with javascript and store it.
    2) Then you could use the wordpress function to get the post ID and your acf values.
    3) Finally, you launch your modal if you get all your needed datas.

    Let me know if it helps,


Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Get fields from a clicked link’ is closed to new replies.