Answer the question
In order to leave comments, you need to log in
Problems with the ACF plugin?
Guys tell me how to solve this problem. Created a custom field. The field type is a link to the page. How to make that in the template on the page this field was displayed with a link and with the name of the page itself?
Example - I created a Venue field. When I select Kiev in the admin panel, for example, the page should look like this
Location: Kiev
I.e. it should display a clickable link with the title of the page. <a href="<?php the_field('location'); ?>"></a>
- this method displays a link, but how to make it also display the name? Thank you all in advance.
Answer the question
In order to leave comments, you need to log in
Either create another field of text type, in which you will specify the title manually, or get the page object by its url.
Create another field with the title of the page and output something like this:
<a href="<?php the_field('location'); ?>"><?php the_field('title');?></a>
It is better to create a field of type "Record object" or there is a function url_to_postid () wp-kama.ru/function/url_to_postid
1. Use the Post Object field www.advancedcustomfields.com/resources/post-object and set it to show you the desired post type
2. Get your post object with get_field()
3. Use the required fields from your object
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question