Custom Field Template
Get shortcode attributes in format using php (1 post)

  1. jrod691
    Posted 2 years ago #

    I am looking for a way to use a shortcode attribute in the php display format so I can reuse a format script for several templates.

    I have several duplicated custom field templates with keys that have incremental indexes on the end such as:

    Template #0:

    Template #1:

    Template #2:


    Say I have the following shortcode:

    [cft template=1 format=1]

    I also have entered a [cft] shortcode format using PHP in the Custom Field Template settings page.

    In that format PHP I want to be able to access shortcode attributes like so:

    $all_custom_fields = base_get_all_custom_fields(); // returns an array of all custom fields on the page;
    $cft_template = ?; //some way to get shortcode template attribute which would be 1 in the above shortcode

    echo '<div>' . $all_custom_fields['content-box-' . $cft_template] . '</div>';

    Anyone know how I can do this? I've been struggling with it for a week now.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Field Template
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic