Support

Account

Home Forums Add-ons Repeater Field Is This Possible?

Helping

Is This Possible?

  • Hello. I currently have a repeater being used as a Gutenberg Block in Posts. It allows me to create a post and add multiple rows of Products with field types that have a title (Text), description (Wysiwyg Editor), image (Image), and Product URL (URL). The Product URL I have to manually enter each time for every row I create in the block repeater. In some instances, the same Product URL will be entered multiple times in different Posts.

    These Product URLs can change in the future. And instead of going into each Post that the Product URL in question was used on, I was thinking of creating a Custom Post Type (Product List) where I can create multiple posts which will house Product URLs in a custom field. Then in the block repeater, the old Product URL field can be a post object allowing me to choose the custom post Product List and extract the Product URL. And if I want to change the URL for any reason, I can do it through the custom post and it will be applied globally to all posts.

    I’ve tried changing the current field from field type url to post object and picking the custom post, but get an error ( ! ) Fatal error: Uncaught Error: Object of class WP_Post could not be converted to string.

    So is what I am trying to do even possible?

  • To change from a url field to a post object field you will have to change the coding in your template. A url field returns a string, a post object field returns a WP_Post Object and you would have to use the ID of that post to get the field you want from the other post.

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

You must be logged in to reply to this topic.