0

how to create a table in WordPress page without using the plugin. I need table Like this Image Link

I think this table created based on custom fields of WordPress. please guide me the code to do this.

1 Answer 1

2

I am not sure i understand the question but if ur looking to create a table you can do it with simple HTML and CSS. Take a look at this: https://www.w3schools.com/html/html_tables.asp

Again, if you need this in all posts then you might consider adding this code inside your theme's loop.php (or other equivalent file which is generating single posts).

Hope this helps!

Addition - 16 June:

I will consider the table “india post recruitment 2017 apply online” in the link as an example. Suppose you created the posts where “Organization” post title and “Qualification, Post Name, No of Posts & Last Date” are the custom meta fields. You can enable them from the screen option available on top of add post page. Add appropriate custom field name and value. Example:

qualifiation: 10th post-name: Gramin Dak Sevaks no-of-posts: 1193 last-date: 24-05-2017

Once you add these and save the post, you can pull the value using the get_post_meta() function. It goes something like this:

$qualification = get_post_meta($post->post_ID, ‘qualification’, TRUE);

Now $qualification will have the value you saved as custom field. Repeat the same for “post-name”, “no-of-posts” & “last-date”

Put the values in table:

<table>
<tr>
    <th> Organization</th>
    <th> Qualification</th>
    <th> Post Name</th>
    <th> No of Posts</th>
    <th> Last Date</th>
  </tr>
<tr>
    <td><?php post_title(); ?> </td>
    <td><?php echo $qualifiation; ?> </td>
    <td><?php echo $post-name; ?> </td>
    <td><?php echo $ no-of-posts; ?> </td>
    <td><?php echo $ last-date; ?> </td>
  </tr>
</table>

This will work assuming you are using WP default loops to generate posts. Please let me know if this helps.

7
  • my requirement is create a table based on custom fields
    – raja
    Jun 15, 2017 at 12:47
  • It would be better if you could share an example so i can provide you some sample code.
    – Sid
    Jun 15, 2017 at 13:07
  • here is the example. link. he is not using html code. how he displayed tables in a page without using plugin. i think fetching data from database into a table. how it is possible
    – raja
    Jun 15, 2017 at 13:42
  • okay.. not quiet what i expected but i will add another answer on this.
    – Sid
    Jun 16, 2017 at 4:20
  • please provide me the code
    – raja
    Jun 16, 2017 at 4:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.