Skip Navigation

[Resolved] Assigning custom fields to one specific page only

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by barryG-4 5 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1193402
screenshot.jpg

Hi,

I have created some custom fields in a custom field group called ‘General Information’.

The idea being that data entered into these fields such as twitter URL etc. can be added to other pages throughout the site using shortcodes. Therefore rather than editing the twitter URL on multiple pages and posts, it’s added to a general information page only seen by editors and the results are seen throughout the site instantly by means of the shortcodes already put in place.

So I have the custom fields but now I need to create a general information page just for editors to edit these unique fields. Where do I go to start this?

I had envisaged creating a page that showed just these fields so I clicked create new page and all the custom fields were already there, but they are also on all the other pages (empty fields) before I click ‘edit with Elementor’.

So how can I make these fields only appear on one specific page i.e. a page created for this purpose called ‘General Information’, so the fields are unique and not universal for all pages, posts etc.

If I can get that done and then enter the data I’m sure I can work out how to add shortcodes to show this specific data.

For example, one of the fields is a date, named 'week-beginning-this-week'. This date will appear on the home page in a ‘schedule’ section and again on a dedicated ‘schedule’ page. Each week the editor would need to enter the date for Monday in this field. I don’t want them to mess about editing the home page or schedule page using Elementor as they could create problems by deleting things and changing the site content containers by mistake so the general information page to edit would give them one non elementor page to edit and the info they enter there would be seen safely on the other pages I created in Elementor that the public sees.

This is probably confusing to read but do you understand what I mean? I'm attaching a screenshot of a custom field, a shortcode (although I don't know what 'types' refers to, I just googled this and tried using it) and the page where the shortcode should result in the outputted field result.

Many thanks,
Barry.

#1193474

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - to display the field group you created with a specific page, please try to add the following code to your current theme's functions.php file:

function func_remove_types_meta_box() {
    global $post_type;
    global $post;
    if($post->ID != 999){
              remove_meta_box( 'wpcf-group-YOUR-FIELD-GROUP-NAME', $post_type,'normal');
                 
    }
}
add_action('admin_head', 'func_remove_types_meta_box' );

Where:
- Replace 999 with your home page ID
- Replace YOUR-FIELD-GROUP-NAME with your custom field group name slug

And then later on whenever you want to display the field value - you should use types shortcode:

For example:

[types field='field-slug-1' id="999"][/types]
[types field='field-slug-2 id="999"][/types]

Where:
- Replace 999 with your page ID

#1204957

My issue is resolved now. Thank you!