如何在自定义`wp_new_user_notification`中运行`WP_Query`?

时间:2018-03-30 06:05:55

标签: wordpress

在WordPress中,我编写了一个自定义电子邮件注册欢迎电子邮件,覆盖了插件中的import {AutoCompleteService} from 'ionic2-auto-complete'; import { Http } from '@angular/http'; import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import 'rxjs/add/operator/map'; @Injectable() export class AutoSuggestProvider implements AutoCompleteService { constructor(public http: HttpClient, public HTTP: Http) { console.log('Hello AutoSuggestProvider Provider'); } getResults(keyword:string) { return this.HTTP.get("https://restcountries.eu/rest/v1/name/"+keyword) .map( result => { return result.filter(item => item.name.toLowerCase().startsWith(keyword.toLowerCase()) ) }); } } 。但是当我尝试在该函数中运行wp_new_user_notification时,查询无效。如何在插件中的WP_Query函数内调用WP_Query?请帮忙。

1 个答案:

答案 0 :(得分:0)

这是因为$post->id无法在插件中运行。相反,我使用get_the_ID()并且它有效。