Support » Fixing WordPress » Category In Title Post Alignment

  • Resolved tallonenx

    (@tallonenx)


    Hey all,

    Running: WordPress 4.4.2 w/ Cubic theme.

    I’m using this code in my Content.php
    to show the category of posts in their title.

    <?php
    foreach( get_the_category() as $category ) {
        $category_name = $category->cat_name;
    }
    echo ' <a class="category-link" href="' . get_category_link( $category->term_id ) . '">' . $category_name . '</a> ' . $post->title;
    ?>

    It works fine on mobile, but on the desktop it doesn’t show properly. It kicks the category name over.

    So I tried to use CSS to align it properly under each post:
    `
    .category-title {
    display: block;
    margin: 0;
    padding: 0;
    }

    I saw one thread on this: https://wordpress.org/support/topic/display-category-title-on-posts?replies=11

    But they seem to never get the alignment issue straightened out.

    Any ideas on how to style or what to do to get the category name under the post block in cubic?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Steve Stern

    (@sterndata)

    Support Team Volunteer

    try changing the display for category title from block to inline-block

    Ok I think I figured it out.

    I just had to put the code in the header for Content.php

    IE: Right before the </header> To call it within the Cubic block post.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Category In Title Post Alignment’ is closed to new replies.