ds15812330851
2015-05-19 15:19
浏览 50
已采纳

在调用短代码时搜索通配符值?

I'm using a Wordpress plugin to generate a form and rather than inserting the form on to the page using the content editor I'm adding it directly to my template.

The problem is that on my local version the id for my form is different to the id of the form on my staging site.

Locally I'm including this in my template to show the form:

<?php echo do_shortcode('[ccf_form id="122"]');?>

But on staging my form has an id of 259 instead, so what I was wondering was, is there a way of searching for a wildcard id? something like:

<?php echo do_shortcode('[ccf_form id="fnmatch(*)"]');?>

or alternately should I find the forms id in phpmyadmin and change it to 122?

I'm using the Custom Contact Forms plugin btw

Please Note

I realise that this question is probably best suited to being on the WP channel but since it's more of a pure PHP question I felt it was worth putting it on here too

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongshanya2008 2015-05-19 15:52
    最佳回答

    I worked out the issue was that I'd previously built another form on my staging site using CCF, I went through phpmyadmin posts and deleted everything ccf-based then rebuilt my form and since there were no previous forms this form was assigned the id 122 and my template now works :)

    It would still be good to know if there's a way to search for wildcards using php as that would be a more scaleable and future proof solution

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题