Customfields name or label
-
Hello,
I’m using catlist with a template.
In this template I’m reading my custom fields:$lcp_display_output .= $this->get_custom_fields($post);On a page I display the customfields using
[catlist customfield_display_name="yes"].Instead of the NAME, I would like to use the LABEL.
That label is used on the edit screen.
How do I display that label on my page?
F.i.:[catlist customfield_display_label="yes"]this doesn’t do the trick
-
Which editor are you using? In the default WP editor I am used to there is “Name” and “Value” for custom fields, no “Label”.
I’m using the default (classic) WP editor.
So in the backend I see the fieldlabel. In frontend I see the fieldname.Ofcourse I can use this in my template:
$field_object = get_field_object( 'Met', $post->ID ); echo $field_object['label'];But I would prefer to get the label with the catlist-command.
In the default WP editor there is no ‘label’. What you are referring to is, if memory servers, the ACF plugin which provides the
get_field_objectfunction. I am afraid the LCP plugin has no direct integration with ACF to support their ‘label’ feature.But I would prefer to get the label with the catlist-command.
So as you can see this is not possible right now, the solution with
get_field_objectyou showed should get it done, though.`I’m using the default (classic) WP editor.
So in the backend I see the fieldlabel. In frontend I see the fieldname.Ofcourse I can use this in my template:
$field_object = get_field_object( ‘Met’, $post->ID );
echo $field_object[‘label’];
But I would prefer to get the label with the catlist-command.`inula (@janetb)
Could you tell me how you solved this issue?
Where to paste your code?
Thank you!-
This reply was modified 3 years, 5 months ago by
lukasdd.
I did not use this code. Just made sure the fieldname was the label I wanted.
I did not use this code. Just made sure the fieldname was the label I wanted.
Thanks for the answer!
It is a pity for me that this is a problem that I have not been able to solve yet.-
This reply was modified 3 years, 5 months ago by
lukasdd.
I think you can solve this bij making a custom-template. You have to put such a template in your childtheme-map in a submap called ‘list-category-posts’.
Copy the default-template in the custom-template (you can find the default-template in the plugin-editor: list-category-posts/templates/default.php) and make some changes like in my question.
On your page you put: [catlist name=”xxxxx” template=yyyyy]**yyyyy is the name of your custom template
`I think you can solve this bij making a custom-template. You have to put such a template in your childtheme-map in a submap called ‘list-category-posts’.
Copy the default-template in the custom-template (you can find the default-template in the plugin-editor: list-category-posts/templates/default.php) and make some changes like in my question.
On your page you put: [catlist name=”xxxxx” template=yyyyy]**yyyyy is the name of your custom template`
//Custom fields:
$lcp_display_output .= $this->get_custom_fields($field_object);
$field_object = get_field_object( ‘timing’, $post->ID );
echo $field_object[‘label’];I did everything as you said but it doesn’t work.
If it’s not difficult, could you send me a piece of the working code.
Thank you!Is your custom template working?
I read here that you should create a folder named list-category-posts under wp-content/themes/your-theme-folder (not in your child-theme as I did).Ваш собственный шаблон работает?
Я прочитал здесь , что вы должны создать папку с именем list-category-posts в wp-content/themes/your-theme-folder (а не в вашей дочерней теме, как я).The template works!
I don’t know where to put your code to make it work.
Maybe it needs to be changed?if ($field_object = get_field_object( 'Met', $post->ID )) echo $field_object['label'];Where Met is the name of the custom field
Put it right after:
//Custom fields: $lcp_display_output .= $this->get_custom_fields($post);//Custom fields:
$lcp_display_output .= $this->get_custom_fields($post);
if ($field_object = get_field_object( ‘timing’, $post->ID ))
echo $field_object[‘label’];So he did everything, does not replace.
Outputs the title at the top of the block to a line.Thats right. Now you have the label available you can find a way to put it where you want.
-
This reply was modified 3 years, 5 months ago by
inula.
Thank you!
But I’ve tried everything and nothing works.
I don’t know how to insert a label instead of a name in the right place.
If you know please help. -
This reply was modified 3 years, 5 months ago by
The topic ‘Customfields name or label’ is closed to new replies.