0

I need to define a custom support feature for my WordPress Plugin but I can't find how to do so.

What I want to do is to display a box on certain custom post type containing 2 meta fields in which users can type in Longitude and Latitudes values for geolocalisation purposes.

For practical uses, i want to attach this custom feature the same way as supports are to posts :

<?php
$args = array(
    ...
    ...
    'supports' => array('title','editor', 'thumbnail', 'my_custom_support'),
    ...
    ...
);
register_post_type('my_custom_post_type', $args);
?>

OR, if my custom post type has already been created beforehand:

<?php
add_post_type_support('my_custom_post_type', 'my_custom_support');
?>

I know what I want but I just can't find how to register new supports ...

I hope someone can answer this problem because I'm actually tearing off my hairs!

1

1 Answer 1

0

Well you can add

...
'supports' => array('title','editor', 'thumbnail', 'custom-fields'),
...

You don't need to create anything beforehand, you can define the two fields latitude and longitude when adding a new post.

2
  • You can also create custom fields programatically, but it's somewhat complicated, and most people just use a plugin like ACF or Pods.
    – D. Dan
    May 16, 2018 at 8:29
  • Thanks D. Dan for this answer but i don't think it solves my problem because afterwards i'll need to query every post type where my custom support appears. If i do it the way you suggested, it would be more difficult to do so because longitude and latitude would appear in every post-types where custom-fields support is set, whereas some custom post type shouldn't have those geolocalisation fields Actually you're right about ACF group fields, it's exactly what i want to have in my posts forms, but i don't want my plugin to depend on ACF
    – Psychotiik
    May 16, 2018 at 8:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.