Category: Code

  • Linking Entire List Element

    I needed a solution for making an entire list element click-able, not just the anchor text.  At the site I made for the Kirksville Brewfest, the entire background color of the list element on the enter page/style changed color, making the user think they could click on it, but only the text was click-able.  The solution I used was to take the anchor text and make its background fill the entire space.  Kirksville brewfest list code:

    ul.styles li a:link,
    ul.styles li a:visited {
    color: #....;
    display: block;
    width: 100%;
    height: 100%;
    }


    Basically, the anchor text fills up the entire li element when there’s an anchor in the ul class “styles”.

    Rad.

  • How to Detect If There’s a Featured Image on a WordPress Page or Post

    I’m redesigning the website for a Mindfulness Practice Center in New Hampshire, Morning Sun Community, and ran into an issue where I didn’t want the Title on the WordPress page to show if there was a featured image. The layout looks cleaner without the title there (although they opted to have the title appear anyways). The php code I used checks for a header image, then if there is one, do nothing. If there isn’t one, throw the title of the post in there.

    <?php
    	//Check if there is a header image
    	if ( has_post_thumbnail( $post->ID ) ) { ?>
    	<?php } else { ?>
    		<h1 class="entry-title"><?php the_title(); ?></h1>
    	<?php } ?>

    The code snippet is pretty useful anytime you want to check for a featured image and do something if there is/isn’t one.

    Have fun!