WordPress add custom field to page without plugin


Master Weems

I am new to WordPress and am building a website using a custom template. The template includes a large banner at the top that can be uploaded via the page's "featured image".

I would like to add the page title on top of this image (this is not a problem), but when creating the page it is possible to specify whether the title is on the left or right (probably a dropdown menu selection).

I've seen many suggestions for similar functionality using the plugin "Advanced Custom Fields", but I can't find a solution that doesn't involve other plugins.

Why can't you just add the functionality you need? Adding a plugin seems a bit overkill to me for such a small functionality.

UPDATE:
OK, after some fiddling I found out that there is a "Custom Fields" option that is not checked in the "Screen Options". My understanding is that these fields are used as key-value pairs that can be accessed in templates using get_post_meta($post_id, $key, $single);a more specific example get_post_meta($post->id, 'my_dropdown_key', true);. I will test it and report the results.

DpEN

Yes, you can use custom fields by checking from the top bar in the admin section of your WordPress page. However, this is not a good solution because it can be confusing after you're sure you have multiple custom fields.

You can use the custom metabox feature for this and then add that functionality to the page, which can be easily done with a plugin called Advanced Custom Fields that you seem to already know about.

So if you don't want to use a plugin, but want to customize it, you can use the function callend add_meta_box . This feature allows you to add individual boxes on a specific post_type.

For a quick tutorial : https://www.sitepoint.com/adding-custom-meta-boxes-to-wordpress/

Hopefully this gives an overview of the meta box. thanks

Related


WordPress add custom field to page without plugin

Master Weems I am new to WordPress and am building a website using a custom template. The template includes a large banner at the top that can be uploaded via the page's "featured image". I would like to add the page title on top of this image (this is not a p

WordPress add custom field to page without plugin

Master Weems I am new to WordPress and am building a website using a custom template. The template includes a large banner at the top that can be uploaded via the page's "featured image". I would like to add the page title on top of this image (this is not a p

WordPress add custom field to page without plugin

Master Weems I am new to WordPress and am building a website using a custom template. The template includes a large banner at the top that can be uploaded via the page's "featured image". I would like to add the page title on top of this image (this is not a p

Add datepicker field to plugin settings page in Wordpress

Renier I'm developing a simple plugin (my first WP plugin development) and I'm trying to add a field datepickerin the plugin settings page using the following code : add_settings_field('example_date_picker', 'Example Date Picker', 'pu_display_date_picker', 'ft

Add datepicker field to plugin settings page in Wordpress

Renier I'm developing a simple plugin (my first WP plugin development) and I'm trying to add a field datepickerin the plugin settings page using the following code : add_settings_field('example_date_picker', 'Example Date Picker', 'pu_display_date_picker', 'ft

Add datepicker field to plugin settings page in Wordpress

Renier I'm developing a simple plugin (my first WP plugin development) and I'm trying to add a field datepickerin the plugin settings page using the following code : add_settings_field('example_date_picker', 'Example Date Picker', 'pu_display_date_picker', 'ft

WordPress add custom page without adding template

Syed Sajid I have a custom page called settings.php in my theme folder that I don't want to use as a page template. How can I keep the URL, let's call it mysite.com/settings, so that URL will load the settings.php page for me? Salas Create a new page called "s

WordPress Custom Plugin Page Redirect

Vasim shaikh Develop plugin but when i click on admin menu works and admin page opens but when i click on page anchor link it doesn't work giving error(attachment). Code gist: <?php /** *Plugin Name: my name *Plugin URI: url for ref *Description: my desciop *

WordPress Custom Plugin Page Redirect

Vasim shaikh Develop plugin but when i click on admin menu works and admin page opens but when i click on page anchor link it doesn't work giving error(attachment). Code gist: <?php /** *Plugin Name: my name *Plugin URI: url for ref *Description: my desciop *

Add button on custom plugin in WordPress

Mahmood Rehman I am using a custom plugin in WP. I have displayed the data in table format. Now I am trying to add functionality to the plugin. But my tables are missing headers and footers like normal data lists like pages and posts in WP. Added new button li

Add button on custom plugin in WordPress

Mahmood Rehman I am using a custom plugin in WP. I have displayed the data in table format. Now I am trying to add functionality to the plugin. But my tables are missing headers and footers like normal data lists like pages and posts in WP. Added new button li

Unable to add custom page in wordpress

All things Magde In wordpress i create custom page <?php /*custom page template*/?> and add it via filezilla, wp-content/themes/twentytwenty/templatesbut when adding the page from the dashboard, I can't find my custom page Eli For example: your template name

Add rich text field in wordpress plugin settings

Kasper Gantzhorn I am developing a simple wordpress plugin to add functionality to some pages. I need a header (I made it with a simple input field) followed by a body (custom message) where I want to use rich text. Is it possible to add a rich text field to m

WordPress plugin: custom edit page in admin area?

Anan I made my own plugin that allows users to subscribe via email. I created mysql table and when user subscribes on frontend email is written to my table. Now, I need some backend functionality. I have table with all user data (name, email, etc). But now I n

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc

Wordpress plugin custom post type single page

Dominic Allen I am using a Wordpress plugin that creates custom post types. This custom post type will need its own single.php page. I know I can create a file called single-{custom post type}.php in my theme, but I need to keep this file in the plugins direct

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc

WordPress plugin: custom edit page in admin area?

Anan I made my own plugin that allows users to subscribe via email. I created mysql table and when user subscribes on frontend email is written to my table. Now, I need some backend functionality. I have table with all user data (name, email, etc). But now I n

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc

Wordpress - custom archive page for post type in plugin

w I've created a very basic plugin that adds a custom post type with several taxonomies and some custom fields. I'd rather use a plugin than simply add it to the theme as I think it might be useful in the future. The problem is that I want to customize the arc