小编Far*_*day的帖子

如何指定 Wordpress API v2 的字段

我在我的项目中使用 WordPress REST API 并将 GET 请求发送到:

http://myblog/wp-json/wp/v2/posts  
Run Code Online (Sandbox Code Playgroud)

它工作得很好,但我想指定字段,尽管我不知道如何。我已经查看了文档,但仍然不知道如何去做。例如,使用公共 API:

https://public-api.wordpress.com/rest/v1.1/sites/www.mysite.com/posts?number=100&fields=title,excerpt,featured_image 
Run Code Online (Sandbox Code Playgroud)

只返回指定的字段。我如何使用 v2 API 做到这一点?

wordpress wordpress-rest-api

5
推荐指数
2
解决办法
5673
查看次数

调用onResponse时应用程序崩溃

我正在使用volley来加载JSON数据.

这是MainActivity

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    private final String TAG = "MainActivity";


    //Creating a list of posts
    private List<PostItems> mPostItemsList;

    //Creating Views
    private RecyclerView recyclerView;
    private RecyclerView.Adapter adapter;
    private RecyclerView.LayoutManager layoutManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.d(TAG, "Device rotated and onCreate called");

        //Initializing Views
        recyclerView = (RecyclerView) findViewById(R.id.post_recycler);
        layoutManager = new LinearLayoutManager(this);
        recyclerView.setLayoutManager(layoutManager);


        //Initializing the postlist
        mPostItemsList = new ArrayList<>();
        adapter = new PostAdapter(mPostItemsList, this);

        recyclerView.setAdapter(adapter);

        if (NetworkCheck.isAvailableAndConnected(this)) {
            //Caling method to get …
Run Code Online (Sandbox Code Playgroud)

java android stack-trace

0
推荐指数
1
解决办法
560
查看次数