• Resolved MRanson

    (@mranson)


    Hi. I’m new to coding and am learning as I go. I’ve created a child theme of Simply Black. I’d like to modify the postmetadata displayed in both post excerpts and single page views, but I’ve been unable to do it using CSS.

    Can you tell me how to make the following changes?

    On the post excerpt I would like to disable the postmetadata so that it isn’t displayed. This would mean removing the black border and infill of div.postmetadata as well.

    On single page view I’d like the following format:
    ‘Posted on MONTH DAY, YEAR in CATEGORY’

    This is a single author site, so doesn’t need the author name. Also, I don’t want to display information about comments.

    When I tried making these changes the ‘By’ was still there, and when I tried removing the ‘No comments’ class it removed the date as well!

    Thanks for your help!

    • This topic was modified 8 years ago by MRanson.
Viewing 15 replies - 1 through 15 (of 18 total)
  • Thread Starter MRanson

    (@mranson)

    Some more specific information: I’ve identified three different php files that seem to control this but don’t know which one to edit.

    content-postmeta.php
    * Postmeta used by files archive, index, search and single.

    content-postmeta-single.php
    * Postmeta used by file single.

    single.php
    * The template for displaying single post.

    I made changes in content-postmeta-single.php to edit the single page view, but these changes also appeared in the blog excerpt.

    I deleted the meta data from content-postmeta.php and this removed the meta from both the excerpt and the single page view!

    It seems I can’t change one without affecting the other.

    Theme Author Guido

    (@guido07111975)

    Hi,

    Sorry, did not notice your post before.

    1) To remove postmetadata from the blog page only, you can add this in your child theme stylesheet:

    
    .blog .postmetadata {display:none;}
    

    The .blog class is added by WordPress itself, and only applies to… the blogpage.

    2) To remove author only, please copy file content-postmeta.php to your child theme folder and change the code into this:

    
    <div class="postmetadata">
    	<?php printf( __( 'Posted on %s', 'simplyblack' ), '<a href="'. esc_url( get_permalink() ) .'"><time class="updated" datetime="'. esc_html( get_the_date('c') ).'">'. esc_html( get_the_date() ).'</time></a>' ); ?> 
    	<?php if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) : ?>
    		<?php echo '|'; ?> <?php comments_popup_link( __( 'No comments', 'simplyblack' ), __( '1 comment', 'simplyblack' ), __( '% comments', 'simplyblack' ) ); ?>
    	<?php endif; ?>
    </div>
    

    This should do the trick.

    Guido

    Theme Author Guido

    (@guido07111975)

    Closing this topic because of no replies.

    Guido

    Thread Starter MRanson

    (@mranson)

    Hi. Sorry for not replying. I was away. I’m restarting this project and will apply your code. (Restarting because I modified at the php myself and a. can’t remember what I did, and b. don’t trust it anymore!) So I’ll probably get back to you over the next few days, if you’re available.

    P.S. good to see you’re still maintaining and updating this theme! I like its simplicity (just like it says in the title!) and the fact that you’ve included mobile responsiveness. So many other themes I was tempted by didn’t, or charged huge monthly rates for the extra feature! So… kudos!

    Cheers

    • This reply was modified 7 years, 8 months ago by MRanson.
    Theme Author Guido

    (@guido07111975)

    Hi,

    Thanks. Yeah, I still maintain/update my (12) themes now and then… besides the new mobile navigation it’s mostly improvements in stylesheet (to avoid things such as margin collapsing). And trying to avoid the use of deprecated functions/actions/filters/etc.

    Guido

    Thread Starter MRanson

    (@mranson)

    Hello again. I’m considering switching to one of your other themes, PrivateBusiness. Would the code you suggest for modifying the comments in SimplyBlack also work for this theme?

    Theme Author Guido

    (@guido07111975)

    Hi,

    Yep, almost the same file and code structure.

    By the way, I’m planning to build a starter theme that contains very basic CSS and multiple layout features, so it can be used as base for building a custom theme.

    Guido

    Thread Starter MRanson

    (@mranson)

    Sounds good. Your watch word must be simplicity in terms of the CMS and configuration tools. And if necessary, some contextual help. This approach would benefit novices and those of us who come back to it after long absences. I started with another theme, called Weaver, which sold me on the basis of being infinitely customise-able, which it is. But it’s also hellishly complicated, as well. By the time you’ve figured it out, you may as well have taught yourself php and started with a blank file. So, that’s a trap to avoid.

    For us end-users the point of this exercise is not to spend all our time fiddling with a website, but to get the site we want up and running as fast as possible and receiving content.

    It must also be mobile responsive, or it won’t get used. Some developers are charging for this feature but I think that policy will bite them in the long run. But, as all your themes are responsive already, I think you already get that! ??

    Cheers

    Thread Starter MRanson

    (@mranson)

    Question: I’m back to using SimplyBlack. How do I move the primary menu from on top of the header image to below it?
    Cheers

    Theme Author Guido

    (@guido07111975)

    Hi,

    I use SimplyBlack as base for most of my custom projects too.

    For that you should adjust file header; relocate whole navigation block (line 32-38). So best practice is to copy file header in your child theme and make changes there.

    Guido

    Thread Starter MRanson

    (@mranson)

    Thanks, done that but I’ve got a gap between the bottom of the header image and the primary menu. How do I close it?

    Theme Author Guido

    (@guido07111975)

    Hi,

    You mean a few px whitespace underneath header image? It has something to do with the line-height of div header… I guess. You can solve this by using a negative margin:

    
    .nav-head {margin:-5px 0 0;}
    

    Not the nicest way, but it does the trick..

    About your previous topic:

    Your watch word must be simplicity in terms of the CMS and configuration tools

    Yes, that’s very important to me as well, that’s why I only use post/page templates (which you can select while adding a post/page) and basic settings via the customizer in dashboard. No fancy content builder with lots and lots of features you never use in real life. And to be honest, I don’t even have the skills to build something like that ??

    Guido

    Thread Starter MRanson

    (@mranson)

    Hi, with reference to the original question, I’d like to remove the text ‘No Comments’ from the metadata using a rule that stops this displaying if there are no comments. If there are comments, I’d still like it to display (i.e. if there is a comment, it will say ‘1 Comment’ as normal). Basically, I don’t want to advertise the fact that there are no comments!

    I’ve been experimenting with variations on this basic rule:

    if ( comments_open() ) {
    if ( $num_comments == 0 ) {
    $comments = __(‘No Comments’);
    }

    …but I can’t get it to work. I keep breaking it. My php Fu is not strong ??

    Theme Author Guido

    (@guido07111975)

    Hi,

    Guess this will work (not tested yet), open file content-postmeta and look for:

    
    <?php comments_popup_link( __( 'No comments', 'simplyblack' ), __( '1 comment', 'simplyblack' ), __( '% comments', 'simplyblack' ) ); ?>
    

    Just remove the “No comments” text:

    
    <?php comments_popup_link( __( '', 'simplyblack' ), __( '1 comment', 'simplyblack' ), __( '% comments', 'simplyblack' ) ); ?>
    

    Guido

    ps. when adding code in a topic, you can click the “code” button before and after your code ??

    Theme Author Guido

    (@guido07111975)

    Hi,

    About a starter theme..

    The only reason to build a starter theme was to replace my 12 themes with this 1 starter theme. Why? Because the layout of my 12 current themes is quite basic (old school maybe?) and maintaining all of them can be a lot of work. Because I want them to stay up-to-date; they must support current version of WordPress at all times.

    But, each of my themes still have a few hundred active installs. So I have updated all of them last week, but this might be the last update.

    Because I’m having trouble creating a nice frontend layout, I have decided not to create this starter theme (yet), but let my 12 current themes listed in the repository for now.

    Guido

Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Modifying post meta data on excerpt and single page views’ is closed to new replies.