• Resolved therinstapp

    (@therinstapp)


    First thing to know is that I am in way over my head here. I’m maintaining a site that was built by someone who was better at WP than me.

    The page I linked with the issue is an example page for my custom post type. For some reason, the style of the post does not match our usual posts (here is an example of the usual post). The left margin is really wide for a reason I can’t figure out.

    I think the issue is that my new post type is not recognizing the formatting in our child theme. I feel like it is something that will have a simple fix, like adding a class to some piece of css, but I am very lost on what it might be. Any help or advice would be appreciated.

    • This topic was modified 1 year, 2 months ago by therinstapp. Reason: messed up the title lol

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Based on what i can see, this CSS selector is reducing the width:

    @media screen and (min-width: 61.5625em) {
    body:not(.search-results) article:not(.type-page) .entry-content {
    float: right;
    width: 71.42857144%;
    }
    }

    From https://www.springfieldlibrary.org/library/wp-content/themes/twentysixteen/style.css?ver=6.7.1 line 3586

    Adding a class of type-page to the <article> html tag in the affected template should fix the width issue.

    Thread Starter therinstapp

    (@therinstapp)

    Sorry, I don’t understand – thank you for pinpointing what part of the CSS is causing the issue, that’s honestly huge.

    The template in our child theme that I had assumed was causing things to be full width doesn’t have an <article> tag in it at all. It’s really abbreviated compared to the full template listing, it just has a <div> tag. Am I barking up the wrong tree? This is everything in the template:

    <?php
    /*
    Template Name: custom_full_width
    */
    get_header(); ?>
    <div id="primary" class="content-area-full">
    <main id="main" class="site-main" role="main">
    <?php
    // Start the loop.
    while ( have_posts() ) : the_post();

    // Include the page content template.
    get_template_part( 'template-parts/content', 'page' );

    // If comments are open or we have at least one comment, load up the comment template.
    if ( comments_open() || get_comments_number() ) {
    comments_template();
    }

    // End of the loop.
    endwhile;
    ?>

    </main><!-- .site-main -->


    </div><!-- .content-area-full -->
    <?php get_footer(); ?>
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    from this:

    get_template_part( 'template-parts/content', 'page' );

    look for a file either in your child theme, or the parent, in a template-parts folder and either named content-page.php or content.php

    Thread Starter therinstapp

    (@therinstapp)

    In content.php, I don’t fully understand what I’m seeing in the article tag, like I don’t know what these functions are doing-

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

    The ID seems irrelevant to my issue. But should the post_class function pull all types of classes, so something is wonky? Or should I add 'type-page' in those parentheses? I’m really sorry for not quite grasping how this works.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Yes, according to https://developer.wordpress.org/reference/functions/post_class/ you can pass in your own classes to get some custom ones. Example:

    <div id="post-<?php the_ID(); ?>" <?php post_class( 'class-name' ); ?>>

    This would put a class-name class on this div.

    For your need, yes adding type-page should suffice:

    <?php post_class( 'type-page' ); ?>>
    Thread Starter therinstapp

    (@therinstapp)

    OMG that worked!!

    One more thing – if I just leave that in my parent theme, will it go away if I download an update? I again have a very slim grasp on how child themes work, but I could go learn how to do it if this won’t be a permanent fix.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Yes, you’d want to get this change into your child theme.

    You should be able to copy/paste the file into a matching folder structure in the child theme and let WordPress handle the rest.

    Thread Starter therinstapp

    (@therinstapp)

    I owe you big time, thank you for all your help.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome πŸ™‚

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Help with format of new post type’ is closed to new replies.