• Resolved Brett_the_Librarian

    (@brett_the_librarian)


    I’m working on my personal website: brettbonfield.com

    I’m trying to alter the way individual posts are displayed. In inc/template-tags.php I’ve changed line 37 from

    echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK.

    to

    echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK.

    And in template-parts/content-single.php I’ve changed line 12 from

    <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>

    to

    <?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>

    It seems like I’ve identified the correct files. On my home page, I have simppeli_posted_on only displaying the posted date and not the byline, but on the individual post it displays both the date and the byline, even though I’m trying to suppress the author. And yet, on the individual post I have successfully changed the H1 to H2.

Viewing 15 replies - 1 through 15 (of 16 total)
  • Theme Author Sami Keijonen

    (@samikeijonen)

    And in template-parts/content-single.php I’ve changed line 12:

    Note that you should copy that file in child your theme in same folder. Otherwise you will lose modifications when I update the theme.

    And I would not recommend changing h1 to h2 on single post. There should be one h1 title on post for better heading structure and accessibility. And it’s good for SEO also.

    If you want to have it smaller font, you can use CSS for that.

    on the individual post it displays both the date and the byline:

    Do you want byline be hidden all the time? You can do that with this CSS in your child theme style.css:

    .single .byline,
    .group-blog .byline {
        display: none;
    }
    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Thanks, Sami, for responding and for creating such a great theme. It’s beautiful and I feel like I understand it pretty well, even though I’m not an expert in developing or modifying themes.

    I’m grateful for the reminder to copy the template-parts/content-single.php file into my child theme. Done!

    I’m kind of old school about H1 elements. I realize HTML5 allows for multiple H1s per page (a big no-no in HTML4 and earlier), but I prefer to limit my pages to just one because it still seems more semantically clear. See The Truth About Multiple H1 Tags in the HTML5 Era and, for a different take, The Truth about “The Truth About Multiple H1 Tags“.

    For the byline, it’s not just that I want it hidden. For privacy and security, I’d also like to keep my username from being included in the source (it’s in the /author/ URL). I’m suppressing lines 32-35 in inc/templage-tags.php in my child theme, but my byline, which includes my username, is still being included in the generated page:

    /**
    *	$byline = sprintf(
    *		esc_html_x( 'by %s', 'post author', 'simppeli' ),
    *		'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>'
    *	);
    **/
    Theme Author Sami Keijonen

    (@samikeijonen)

    For privacy and security, I’d also like to keep my username from being included in the source:

    Note that your username is not a secret.

    I’m kind of old school about H1 elements. I realize HTML5 allows for multiple H1s per page (a big no-no in HTML4 and earlier), but I prefer to limit my pages to just one because it still seems more semantically clear.

    That’s something that I can fix in the parent theme. In single post there is not need to have site title as h1 but post title should be h1. This is how I can do it.

    Theme Author Sami Keijonen

    (@samikeijonen)

    H1 hierarchy will be fixed in version 1.0.4.

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Thanks for updating the h1 in 1.0.4. I’ve updated to this version and it works great!

    I realize my username is not a secret, but even the article you linked to discusses the possibility of confusing script kiddies. And other security expert have written that it does make sense to Hide WordPress Usernames to Improve WordPress Security. I’ve used phpMyAdmin as advised in the article to which I linked, but there are two up-to-date and well reviewed plugins that offer the same feature:

    Do you know why I’m unable to suppress the /author/ URL in the source? It seems like what I’m doing should work, but the URL is still there.

    Theme Author Sami Keijonen

    (@samikeijonen)

    I’d ask that from plugins support forum if that’s what those plugins do.

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Sorry for not asking my question clearly. There are three issues:

    1. Is there any point in obscuring usernames? I think the answer is, “Maybe”. That’s good enough for me, but I can see why some people might not want to bother doing it.

    2. Are there any techniques within WordPress itself, or its underlying software, to obscure usernames? Yes, there are. There are two plugins that will help you do it, or you can drop into MySQL either directly or through an interface like phpMyAdmin.

    3. Are there any techniques within the theme, Simppeli (or, more accurately, within a child theme of Simppeli) to hide URLs that reveal usernames? Probably, but I can’t figure it out. I feel like I’ve identified the part of the code that displays author URLs and I feel like I’ve modified that part of the code in a way that should prevent the author URL from being displayed within the child theme, but what I’ve done isn’t working: the author URL is still being served through the browser and is available to anyone using view source directly in a browser or doing the equivalent operation with a scraper or other script. I want to suppress that HTML from being made available to my site visitors, but I can’t seem to do it. Is there any way I can accomplish my goal?

    Theme Author Sami Keijonen

    (@samikeijonen)

    1. Not if you ask me:) That’s not on top of my security list.

    2. I think you already had the answer to this.

    3. Which URL are you referring?

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Which URL are you referring?

    On the page that displays individual posts, I’d like to suppress the URL that appears here:

    <span class="byline"> by <span class="author vcard"><a href="https://www.domain.tld/author/user-name/">User Name</a></span></span>

    Theme Author Sami Keijonen

    (@samikeijonen)

    It’s important to note that it’s plugin territory to do something about the url https://www.domain.tld/author/user-name/. WP is generating author “page” and URL anyways even if your theme doesn’t output it anywhere.

    WP is outputting author username for example in body class and feed URL. So there is much more you need to do if you want to keep your username secret. Plugins you listed before might do all this.

    With all that said there are several ways you can do this:

    1. Just hide it via CSS like you do now. I know, not a solution you want:)

    2. Copy template-parts/content-single.php in your child theme and replace this line with your own code without author URL.

    <?php simppeli_posted_on(); ?>

    3. simppeli_posted_on()-function is also pluggable function. It means that you can copy the funcion in your child theme’s functions.php` and make modifications in there.

    That’s something I can’t really recommend because I don’t think pluggable functions are the right way to modify themes.

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Thanks for helping me through this. I’ve gone with #2 (thanks for warning me about #3 so I could avoid it). For anyone else following this thread or who might refer to it later, here’s the code I used for the <header> in template-parts/content-single.php:

    <header class="entry-header">
    		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    
    	<div class="entry-meta">
    		<span class="posted-on"><?php the_time('j F Y') ?></span>
    	</div><!-- .entry-meta -->
    	</header><!-- .entry-header -->

    and here’s what I used in my child theme for the relevant section in template-parts/content.php

    <?php if ( 'post' == get_post_type() ) : ?>
    	<div class="entry-meta">
    		<?php the_time('j F Y') ?>
    	</div><!-- .entry-meta -->
    	<?php endif; ?>

    I didn’t see my author name in the body class or my feed URL. If you do, would you tell me how to find the areas in which my username is mentioned?

    Regardless, I’ll mark this thread as resolved. Again, I really appreciate all your help with this request.

    Theme Author Sami Keijonen

    (@samikeijonen)

    From here.

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    Thanks for pointing this out. How would a site visitor find that page if they didn’t already know the author name?

    Theme Author Sami Keijonen

    (@samikeijonen)

    Well, because your username is not a secret??

    Theme really doesn’t play any role in this. This is security plugin territory.

    Thread Starter Brett_the_Librarian

    (@brett_the_librarian)

    I don’t understand. How would someone find that URL if they didn’t already know the authorname? I’ve just gone in through phpMyAdmin and changed the authorname for my feed, then deleted my old post and created a new one. Are you still able to find my authorname?

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Modifying simppeli_posted_on’ is closed to new replies.