Support » Fixing WordPress » Adding a custom field inside shortcode in my page template

  • Hello, I am trying to add a custom field to my page template, but I am trying to insert it in between some existing shortcodes from a plugin. My end goal is to have tabs (which are being placed in my template by shortcodes) and have my client be able to select a custom field to add content to each of the tabs. Here is the code I added to my page.php template

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Is there anyway to do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Here is the code

    <?php echo do_shortcode('[wptabs]
        [wptabcontent]<?php echo get_post_meta($post->ID, 'fieldtext', true); ?> [/wptabcontent]
        [wptabcontent] Contents of the Quotes tab [/wptabcontent]
        [wptabcontent] Contents of the Tables tab [/wptabcontent]
    [/wptabs]'); ?>

    Wait, you’re adding PHP to a WordPress page?

    Isn’t it better if you used extra arguments for your shortcodes?

    And then use it like this:


    <div class='wptabs'>
    [wptab title='News']content[/wptab]
    [wptab title='Stats']content[/wptab]
    [wptab title='Pedigree']content[/wptab]

    I don’t see why you have to use Shortcodes to do this though…

    Well the shortcodes enable the tab plugin I am using to work, just adding the div tags to the page.php does not enable the tabs. I have to use the php echo do_shortcode to make them work. My end goal is to have a page template my friend can select and then the tabs are automatically on the page, but I want him to be able to use custom fields to add the content for each tab, since I will not be adding it and he is not able to hand code them. Does that make since?

    Can you show us the code how the tab plugin shortcode is being generated?

    Search for this add_shortcode in your tab plugin’s folder and it’s function.

    Did you ever get this to work? Its exactly what I’m looking for..

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding a custom field inside shortcode in my page template’ is closed to new replies.