Hello World Master

Tutorials, articles and quizzes on Software Development

PHP > Articles

Returning information in our WordPress plugin

We now have the structure for a WordPress plugin, so lets now pull information from WordPress into our plugin.

Getting Posts

For getting posts, its as simple as using the get_posts function.

Since get_posts returns an array, we can’t use echo, so lets use print_r insteads

In our VictoryflameView.php file

<h1> I am the page your menu directed you to</h1>
<?php
  print_r(get_posts());
?>

Getting Categories

To get categories we need to use the get_categories function

<h1> I am the page your menu directed you to</h1>
<?php
  print_r(get_categories());
?>

Getting Tags

To get categories we need to use the get_tags function

<h1> I am the page your menu directed you to</h1>
<?php
  print_r(get_tags());
?>