• cscott5288

    (@cscott5288)


    Hey folks,

    So I am designing my first theme but I have run into a little confusion.

    I am setting up my index.php file and I am trying to insert the php tag that calls out the CSS for the div that contains my post area.

    In my HTML rough, I have the post area selected via ID, like div#postarea. That would be the correct way to do it right? I was under the impression that classes are for multiple occurring elements and the post area only occurs once on a page so, therefore, I should use an ID?

    The problem is that I don’t see a tag in the WordPress codex that calls upon an ID for the post area, there is only one for class: https://codex.www.ads-software.com/Template_Tags/post_class

    Also, I was wondering if anyone could direct me to a list of necessary tags and explanation of each. I am still a little unclear as to how WordPress knows which ids and classes (which you name) are used with the php integration for the template. Are all of your div names ‘registered’ or something like that in the functions.php file?

    Thanks..

Viewing 7 replies - 1 through 7 (of 7 total)
  • esmi

    (@esmi)

    That would be the correct way to do it right?

    Nope. Each post on the page will use the same div and hence the same id (unless you also make use of the post_id to create a unique CSS id-per-post). Since the div will re-occur, it makes send to use a class. post_class() is a good tool for this.

    Are all of your div names ‘registered’ or something like that in the functions.php file?

    No – they’re simply used as they appear in your template files and then styles via your CSS.

    Thread Starter cscott5288

    (@cscott5288)

    OK, that makes sense actually. I was only considering when posts were displayed on individual pages.

    OK so if the class name in my CSS is postarea, what will my tag look like?

    <div <?php postarea() ?>>

    or am I doing it wrong?

    Thanks

    esmi

    (@esmi)

    Just use <div class="postarea">

    Thread Starter cscott5288

    (@cscott5288)

    OK thanks. I have another question though.

    Let’s say I have a div container in the header where I want to be able to place widgets.

    What do I change in the coding to allow widgets? So that I can drag and drop widgets in admin cp –> widgets.

    Thanks..

    Thread Starter cscott5288

    (@cscott5288)

    p.s. I read the widgitizing themes page by auttomatic: https://automattic.com/code/widgets/themes/
    but I am not really sure if that is just old information.

    Do I really just add that one like of code after the UL tag? Can I do that to
    uls that are not in sidebar.php? in header.php instead?

    thanks

    Thread Starter cscott5288

    (@cscott5288)

    p.p.s I meant to say that one line of code: <?php if ( !function_exists(‘dynamic_sidebar’)
    || !dynamic_sidebar() ) : ?>

    in the div container of the sidebar.

    Thread Starter cscott5288

    (@cscott5288)

    nvm … i figured it all out pretty much.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘post_class or post_id?’ is closed to new replies.