WP Template help needed!

darnoldy

Curmudgeon
Joined
Dec 20, 2004
Messages
1,733
Have I mentioned how much I hate WordPress...

I'm trying to move an element on post page:

If you look at the attached image, I want to move the category from where it is, under the author and date, to on top of the Post title.

The existing template code for the article is:
HTML:
<!-- START content-single Template (template-parts/content-single.php) -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    </header><!-- .entry-header -->

    <?php twentysixteen_excerpt(); ?>

    <?php twentysixteen_post_thumbnail(); ?>

    <div class="entry-content">
        <?php
            the_content();

            wp_link_pages( array(
                'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentysixteen' ) . '</span>',
                'after'       => '</div>',
                'link_before' => '<span>',
                'link_after'  => '</span>',
                'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>%',
                'separator'   => '<span class="screen-reader-text">, </span>',
            ) );

            if ( '' !== get_the_author_meta( 'description' ) ) {
                get_template_part( 'template-parts/biography' );
            }
        ?>
    </div><!-- .entry-content -->

    <footer class="entry-footer">
        <?php twentysixteen_entry_meta(); ?>
        <?php
            edit_post_link(
                sprintf(
                    /* translators: %s: Name of current post */
                    __( 'Edit<span class="screen-reader-text"> "%s"</span>', 'twentysixteen' ),
                    get_the_title()
                ),
                '<span class="edit-link">',
                '</span>'
            );
        ?>
    </footer><!-- .entry-footer -->
</article><!-- #post-## -->
<!-- END content-single Template (template-parts/content-single.php) -->
As far as I can determine, that whole block with the author, date, etc is generated by:
PHP:
        <?php twentysixteen_entry_meta(); ?>
But I can't find where that function is defined! I couldnt find it in functions.php—where I would expect it to be.

Any suggestions, anyone?
 

Attachments

we_are_borg

Administrator
Joined
Jan 25, 2011
Messages
5,511
If you give a link to your site people can inspect it thats faster then staring at a code.
 

Deathstarr

Forum Owner
Joined
Mar 15, 2011
Messages
351
it will be found in the twentysixteen/inc/ folder under template-tags.php/

The best way wold be to CSS it out if thats what your trying to do.

.author {display:none;
}
 

PoetJC

⚧ Jacquii: Kween of Hearts ⚧
Joined
Jul 9, 2006
Messages
21,043
Hmmm... I'm not at all familiar with the WP 2016 theme tbh...

But it would see the code generating the actual category link is like Deathstarr said - within the wp-content\themes\twentysixteen\inc\template-tags.php file
The code generating the actual content page is actually in the wp-content\themes\twentysixteen\template-parts\content-single.php file though.

I'm not at all sure this will work, as I'm not really that proficient in php ... But try finding:
Code:
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
in content-single.php and replace it with:
Code:
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>
The entire function can be found on lines 94-111 of the template-tags.php file.:
Code:
function twentysixteen_entry_taxonomies() {
    $categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
    if ( $categories_list && twentysixteen_categorized_blog() ) {
        printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
            _x( 'Categories', 'Used before category names.', 'twentysixteen' ),
            $categories_list
        );
    }

    $tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'twentysixteen' ) );
    if ( $tags_list ) {
        printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
            _x( 'Tags', 'Used before tag names.', 'twentysixteen' ),
            $tags_list
        );
    }
}
endif;
What I did basically is examine the code in Chrome developer tools and found the cat-links css class. I searched the wordpress 2016 theme directory using the free tool TextCrawler 3 found at https://www.digitalvolcano.co.uk/ ... It's a free utility and definitely worth the download if you examine and/or compare a lot of different types of code.

At anyrate - IDK if this'll help. But I hope it does.

J.
 

darnoldy

Curmudgeon
Joined
Dec 20, 2004
Messages
1,733
Thanks Deathstarr & PoetJC

template-tags.php was the hint I needed.

Turned out that the category (and tags, if I used them) were added by a nested function:
PHP:
twentysixteen_entry_taxonomies()
I was able to comment that out of
PHP:
 twentysixteen_entry_meta()
and paste it into the page template where I wanted it!

The page (with some CSS tweaking) now looks like:
Picture 3.png
 

PoetJC

⚧ Jacquii: Kween of Hearts ⚧
Joined
Jul 9, 2006
Messages
21,043
Thanks Deathstarr & PoetJC

template-tags.php was the hint I needed.

Turned out that the category (and tags, if I used them) were added by a nested function:
PHP:
twentysixteen_entry_taxonomies()
I was able to comment that out of
PHP:
 twentysixteen_entry_meta()
and paste it into the page template where I wanted it!

The page (with some CSS tweaking) now looks like:
View attachment 45545
Great! Glad it worked out and thanks for posting how you solved the issue. It could come in handy for others wanting to accomplish the same or similar theme revision.
And wow. Looks like the blog is going to have some rather intriguing content. Best of luck with it ;)

J.
 

darnoldy

Curmudgeon
Joined
Dec 20, 2004
Messages
1,733
PoetJC —the site is not mine...its part of a larger project I'm working on for this non-profit. Eventually, there'll be an internal site, and two or three external sites (each aimed at a different audience).
 

PoetJC

⚧ Jacquii: Kween of Hearts ⚧
Joined
Jul 9, 2006
Messages
21,043
PoetJC —the site is not mine...its part of a larger project I'm working on for this non-profit. Eventually, there'll be an internal site, and two or three external sites (each aimed at a different audience).
Ha. And here I was getting ready to offer my stellar WP consultation skills :p:ROFLMAO:
Best of luck with the sites!

J.
 
Top