附加Wordpress永久链接URL

时间:2015-12-10 10:47:22

标签: php wordpress

我正在尝试修改一个在电子邮件通知中发送url的插件。

插件中的代码是

<?php the_title(); ?>: <?php the_job_permalink(); ?>

它在电子邮件中显示以下内容

前端风险客户经理:http://tbc-recruit.com/job/front-end-risk-account-manager/

我想最终得到的是这种格式的网址

http://tbc-recruit.com/job/front-end-risk-account-manager/?utm_source=jobalerts&utm_medium=email

我试过以下

<?php 
$alerturl = the_job_permalink();
$alerturl .= "?utm_source=jobalerts&utm_medium=email";
?>

<?php the_title(); ?>:<?php echo $alerturl; ?>

该代码提供以下输出

前端风险客户经理:?utm_source = jobalerts&amp; utm_medium = email

2 个答案:

答案 0 :(得分:2)

可能因为the_job_permalink()显示html内容,如

<a href="http://tbc-recruit.com/job/front-end-risk-account-manager/">http://tbc-recruit.com/job/front-end-risk-account-manager/</a>

您应该使用get_permalink()

<?php
$alerturl = get_permalink() . '?utm_source=jobalerts&utm_medium=email'; 
?>
<?php the_title(); ?>:<?php echo '<a href="' . $alerturl . '"> ' . $alerturl . '</a>'; ?>

我希望这有助于你

答案 1 :(得分:0)

使用Error: [$parse:syntax] Syntax Error: Token '{' is unexpected, expecting [)] at column 143 of the expression [$http.get('http://server/GeneralHandler.ashx?method=GetDataFromHandler&Parameters=5,633,2015-12-12,2015-12-12,0').then( function(res) {alert(res);},function(err) {alert(err);})] starting at [{alert(res);},function(err) {alert(err);})].http://errors.angularjs.org/1.4.7/$parse/syntax?p0=%7B&p1=is%20unexpected%2C%20expecting%20%5B)%5D&p2=143&p3=%24http.get('http%3A%2F%2surver%2FGeneralHandler.ashx%3Fmethod%3DGetDataFromHandler%26Parameters%3D5%2C633%2C2015-12-12%2C2015-12-12%2C0').then(NaNunction(res)%20%7Balert(res)%3B%7D%2Cfunction(err)%20%7Balert(err)%3B%7D)&p4=%7Balert(res)%3B%7D%2Cfunction(err)%20%7Balert(err)%3B%7D) at http://localhost:4400/lib/angular/angular.js:68:12 at Object.AST.throwError (http://localhost:4400/lib/angular/angular.js:13057:11) at Object.AST.consume (http://localhost:4400/lib/angular/angular.js:13069:12) at Object.AST.primary (http://localhost:4400/lib/angular/angular.js:12967:14) at Object.AST.unary (http://localhost:4400/lib/angular/angular.js:12940:19) at Object.AST.multiplicative (http://localhost:4400/lib/angular/angular.js:12927:21) at Object.AST.additive (http://localhost:4400/lib/angular/angular.js:12918:21) at Object.AST.relational (http://localhost:4400/lib/angular/angular.js:12909:21) at Object.AST.equality (http://localhost:4400/lib/angular/angular.js:12900:21) at Object.AST.logicalAND (http://localhost:4400/lib/angular/angular.js:12892:21)` 代替get_the_title()