0

The WordPress plugin I am currently writing restricts access to posts and pages and hides them for unauthorized users. In the options page for the setting I'd like to include overview tables that show what posts or pages actually have redirection or hiding enabled.

I am new to WordPress, PHP, HTML and CSS, so I find myself lost in creating this table. Currently the header misses left padding and the table is too wide (more noticable on fullscreen desktop).

enter image description here

The code uses an array $hidden_pages that holds the page objects to be displayed. I just used some of the CSS classes from the WordPress page overview.

<table class="widefat striped">
    <thead>
        <tr>
            <th scope="col" id="redirected-name">Name</th>
        </tr>
    </thead>
    <tbody>
        <?php foreach ( $marked_pages as $index => $page ): ?>
            <tr>
                <td>
                    <a href="<?php echo get_the_permalink( $page->ID ); ?>"><?php echo get_the_title( $page->ID ); ?></a>
                </td>
            </tr>
        <?php endforeach; ?>
    </tbody>
</table>

What are some ressources to learn more about tables, especially in the context of WordPress?

  • I think you're on the right track. I would say your best resource is reading source code from another WordPress table. – Jeremy Ross Sep 16 '16 at 17:38
0

You are on the right track and this is about as far as WP gets you.

WordPress does not have official style guides. There are some unofficial efforts to create one now and then, but they tend to wither and only sporadically maintained.

The practical (necessary) approach is to study markup of most current version, use it as much as possible, and get the rest done with custom CSS.

In your case if WP doesn't have a native case of table in such context (I don't think it does) you will have to adjust it with custom CSS. Always be careful to only load your CSS when needed and that it doesn't interfere with the rest of admin.

  • Are there any ressources for learning CSS that you would reccomend? :) – J0hj0h Sep 16 '16 at 19:31
  • 1
    Not really, I try to write as little CSS as possible and leave it to people who are good at it. :) – Rarst Sep 16 '16 at 19:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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