• I have no knowledge of php/css, etc.
    The Edit Post page of WP admin has 2 entries under Custom Fields.
    One for ‘hide-author’ and one for ‘hide-date’–but no values assigned.

    I read the codex article on Custom Fields, but have no idea how to actually implement
    these to hide the post author/date/time on a per post basis—to decide with each post whether or not to display the author/date/time.

    Does anyone know how to do this?

    I saw other posts describing code changes to index.php, category.php, etc.
    to remove author/date/time from ALL posts,
    but I’m hoping to find a way to pick and choose which posts have author/date/time removed from the display.

    I looked for a plugin to do this but could not find any…

    Thanks,
    Charles

Viewing 2 replies - 1 through 2 (of 2 total)
  • Those custom fields have either come from a theme that you used previously or an old plugin. Given that you can’t hide author and/or post dates now, I think it’s safe to assume that this isn’t a feature in your current theme. Which means it would have to be added to the relevant template files in your current theme (eg index.php, category.php, archive.php, single.php etc).

    Something like:

    <?php
    if(!get_post_meta($post->ID, 'hide-author') || get_post_meta($post->ID, 'hide-author',true) != 'yes' ):?>
    [.. author markup ..]
    <?php endif;?>
    
    <?php
    if(!get_post_meta($post->ID, 'hide-date') || get_post_meta($post->ID, 'hide-date',true) != 'yes' ):?>
    [.. date markup ..]
    <?php endif;?>

    should work – assuming you entered “yes” (without the quotes) into the relevant custom field whenever you wanted to hide this data. Not tested it out though – so apologies if there are any syntax errors in there.

    Thread Starter chasapple

    (@chasapple)

    Thank you very much for the reply.
    I’ll fiddle with it and post back if I’m able to get it to work.

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

The topic ‘use Custom Fields to hide post author/date/time’ is closed to new replies.