WordPress-post_category没有显示结果

时间:2019-05-22 08:05:39

标签: php wordpress templates posts

我正在尝试为我页面的最新帖子创建一个概述。一切都可以通过“ wp_get_recent_posts”查询正常运行。现在,我试图在标题中添加一些图标,但是,一旦我尝试获取帖子的 post_category ,它始终不会显示任何结果。

如果尝试将 $ args 'category'=>更改为' 1 2 3 4 ,...”,但没有帮助。

任何建议都将受到高度赞赏。我的代码:

#include <iostream>
#include <fstream>
#include <string>
#include <iterator>
#include <vector>
using namespace std;

int main() {

    ifstream xfile;
    string input;
    double num=0;
    int count = 0;
    vector <double> myvector;
    cout << "Input the file: ";
    cin >> input;

    xfile.open(input);

    if (xfile.is_open()) {
        cout << "File accessed!" << endl;
        while (getline(xfile, input)) {
            count++;
            myvector.push_back(num);
        }

    }

    else {

        cout << "File opening failed!"<<endl;
    }


    cout << "Numbers of lines in the file : " << count << endl;

    for (int i = 0; i < myvector.size(); i++) {

            cout << myvector[i] << "\t";

        }
    cin.fail();
    return 0;
}

1 个答案:

答案 0 :(得分:0)

post对象没有post_category属性:https://codex.wordpress.org/Class_Reference/WP_Post

您可以将get_the_category函数与帖子ID(https://developer.wordpress.org/reference/functions/get_the_category/)结合使用:

df %>%
 group_by(Patient) %>%
 mutate(episode = temperature > lag(temperature, default = first(temperature))) %>%
 group_by(Patient, rleid = with(rle(episode), rep(seq_along(lengths), lengths))) %>%
 mutate(episode = (n() >= 2) * episode) %>%
 ungroup() %>%
 select(-rleid) %>%
 left_join(df %>%
            group_by(Patient) %>%
            mutate(episode = temperature < lag(temperature, default = first(temperature))) %>%
            group_by(Patient, rleid = with(rle(episode), rep(seq_along(lengths), lengths))) %>%
            mutate(episode = ((n() >= 2) * episode + 1) * episode) %>%
            ungroup() %>%
            select(-rleid), by = c("Patient" = "Patient",
                                   "Minute" = "Minute",
                                   "temperature" = "temperature")) %>%
 mutate(episode = pmax(episode.x, episode.y)) %>%
 select(-episode.x, -episode.y)
相关问题