How To Add Custom Fields to Custom Page Template

Community Forums Forums Design Tips and Tricks How To Add Custom Fields to Custom Page Template

This topic is: not resolved

This topic contains 5 replies, has 2 voices, and was last updated by  Just Me 2 years, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #50739

    Just Me

    I have created a custom page template called single-clients.php. It is pulling in a Custom Post Type called Client, which I setup in Custompress. This all seems to be working fine.

    My problem is that I am not proficient enough in PHP to be able to pull in my custom field types.

    Can you help?

    This is what I have in my template:

      * @author Tech Geek Ministries
    Template Name: Clients Page
     * This removes the loop.
     * If you want to include the static page title and content,
     * remove or comment out this code.
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'tgm_custom_loop' );
    function tgm_custom_loop() {
                //WP Query Start
                $per_page = 9;
                $clients_args = array(
                    'post_type' => 'clients',
                    'posts_per_page' => $per_page,
                                    'paged' => get_query_var( 'paged' )
                $clients = genesis_custom_loop( $clients_args );
    /** Move Post Info */

    And here is a php code for one of my custom fields:

    <?php echo do_shortcode('[ct id="_ct_datepicker_51e310a9c8a48" property="title | description | value"]'); ?>

    I’m not sure how to put the two of these together.


    Could you paste the PHP for your custom fields in Pastebin or Githib Gists and link to it from here please. Thanks

    You could do what is needed without using a custom page template and simply use your child themes functions.php file.

    I always test my code however in this case, i didn’t because i don’t have a custom post type setup for clients and don’t have a custom template named single-clients.php created.

    You can easily change the hook position where you want to display your date picker.


    Just Me

    I tried this code, but nothing showed up on my page. I checked both the clients page and a single post page with the client content, but the custom field did not appear.

    I also tried pasting in the code from Pastbin, but the forum software is stripping the HTML out.

    • This reply was modified 2 years, 4 months ago by  Just Me.
    • This reply was modified 2 years, 4 months ago by  Just Me.
    • This reply was modified 2 years, 4 months ago by  Just Me.
    • This reply was modified 2 years, 4 months ago by  Just Me.


    Not sure what code you used to create the custom field. Did you use the native WordPress custom fields, code or a plugin to create the custom fields?

    The code snippets above are simply an example of how to execute shortcodes using the custom post the conditional and page template conditional. You wouldn’t need a shortcode for a custom field if you use the correct code to create it.



    Please try the second code snippet again and see if it works. I have changed it slightly.


    Just Me

    I am using custompress to create my CPTs.

    I added the single quotes around single-clients.php, and changed property=”title | description | value” to property=”value” and my first custom field type appeared. Yeah!!!

    Now my second quandary: Getting the rest of my custom fields for this CPT to appear…

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

You must be logged in to reply to this topic.