Plugin Planet

Premium WordPress Plugins

Here are the steps to replace the default Post Title with the one that’s submitted via USP Form Custom Field.

So for example, let’s say that you want to include a field in a form to collect a custom post title, and then display that title for the submitted post (instead of the default Post Title). Here are the steps:

Step 1: Add the Custom Field

Here we will add a form field that will collect the custom title info from the user. To do this, we need to define a Custom Field. First scroll down a bit beneath the USP Form content editor (in the WP Admin Area) and define a custom field, for example:

data-required#true|label#Custom Title|Placeholder#Custom Title

Once that is in place, add the Custom Field to the USP Form using its shortcode (located to the left of the custom-field definition), for example:

[usp_custom_field form="1234" id="1"]

In your case, the 1234 and 1 may be different, as the values are auto-generated for each form.

Step 2: Display the Custom Field

With your USP Form set up and the Custom Field in place, open the theme template file(s) for the page view(s) for which you would like to display the custom title. This can be tricky, but you can always search for the_title() in your theme files to help narrow it down. In most themes, the templates that display the Post Title are single.php (or content.php), index.php, archive.php, et al.

Pro Tip: Master the WordPress theme template with my book, WordPress Themes In Depth. Equip yourself with the skills needed to customize and build your own WordPress themes!

Once you have determined which theme files are responsible for displaying your post content, locate <?php the_title(); ?> and replace it with the following USP tag:

<?php echo usp_get_meta(false, 'usp-custom-1'); ?>

Note that the usp-custom-1 must match with the actual custom field ID that is used in the form. You can always find this information displayed in the Custom Fields panel on the “Edit Post” screen.

That’s all there is to it. Here is more info on displaying custom fields for your FYI:

Related Infos