Displaying Multisite ID number

I'm wondering if there is a way to add in a site ID in some code. Long story short we are connecting sales force to

I'm wondering if there is a way to add in a site ID in some code. Long story short we are connecting sales force to display data on our multipress website.

I am wondering if there is a way to add in the ID to the shortcode so that it will dynamically display and I can make a template as to make changes easier later on. So in the sample below I am looking to make the Playhouse__c='a0q50000005qQbo' into something like Playhouse__c='[site_id]'

i.e. we are using

[sectionsforce o="Playhouse_Prog_Vol_Job__c" filter="Display_on_Websites__c =true and Playhouse__c ='a0q50000005qQbo' and Active__c=true and Ages_Served__c='All Ages'"  n="100" ]

{!Playhouse_Program_Website_Image__c}

{!ProgVol_Job_Name__c}

Description: {!Global_Description__c}
Location Information: {!Location_Program_Description__c}
[/sectionsforce]

I'm wondering if there is a way to add in a site ID in some code. Long story short we are connecting sales force to display data on our multipress website.

I am wondering if there is a way to add in the ID to the shortcode so that it will dynamically display and I can make a template as to make changes easier later on. So in the sample below I am looking to make the Playhouse__c='a0q50000005qQbo' into something like Playhouse__c='[site_id]'

i.e. we are using

[sectionsforce o="Playhouse_Prog_Vol_Job__c" filter="Display_on_Websites__c =true and Playhouse__c ='a0q50000005qQbo' and Active__c=true and Ages_Served__c='All Ages'"  n="100" ]

{!Playhouse_Program_Website_Image__c}

{!ProgVol_Job_Name__c}

Description: {!Global_Description__c}
Location Information: {!Location_Program_Description__c}
[/sectionsforce]
Share Improve this question edited Aug 2, 2019 at 21:43 Antti Koskinen 6,0538 gold badges15 silver badges26 bronze badges asked Aug 1, 2019 at 20:08 JenJen 1
Add a comment  | 

1 Answer 1

Reset to default 0

If the shortcode you're using provides a standard format filter for the shortcode attributes, then you could perhaps try something like this.

function filter_shortcode_atts_sectionsforce( $out, $pairs, $atts, $shortcode ) {
  // is filter set and it contains our dynamic tag
  if ( isset( $atts['filter'] ) && false !== strpos( 'Playhouse__c=\'site_id\'', $atts['filter']  ) ) {
    // get ID, could use some custom helper function here, if complex logic is required
    $site_id = get_current_blog_id();
    // Simple string replacement to replace dynamic part with real data
    $out['filter'] = str_replace( 'Playhouse__c=\'site_id\'', "Playhouse__c='{$site_id}'", $atts['filter'] );
  }
  return $out;
}
add_filter( 'shortcode_atts_sectionsforce', 'filter_shortcode_atts_sectionsforce', 10, 4 );

Ot if the shortcode (and its callback) is your own code then use the check above in our callback.

Also, based on https://stackoverflow/questions/30490175/use-wp-shortcode-as-an-attribute-in-another-shortcode, I think trying to use [site_id] in a paramater has the potential to break the shortcode, because the shortcode parser might freak out from those extra brackets. That's why I didn't include them in my example above.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745274093a4619929.html

相关推荐

  • Displaying Multisite ID number

    I'm wondering if there is a way to add in a site ID in some code. Long story short we are connecting sales force to

    1小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信