Fixing anchor links that scroll too far down the page

For the second time, I needed to adjust the CSS for a site that is using anchor links. The problem was, the page would scroll down too far because of a fixed menu at the top of the page, and the anchor link area ended up underneath the menu.

The fix is to add this to the site’s CSS:

:target:before {
content:””;
display:block;
height:55px; /* fixed header height*/
margin:-55px 0 0; /* negative fixed header height */
}

Change the height and margin to match the height of the fixed menu. Sometimes the display setting needs a little tweaking, too. Woo!

Adding stuff after the body tag in WordPress

Today I had to add some retargeting code to a site, and my research revealed that I needed to add it to the functions.php of the theme. No problem.


function jr_add_floodlight_retargeting() {
// Added 4/14/21 by EKB to put code on landing page for Floodlight campaign 
   if ( isset( $_GET['utm_source'] ) ) {
      if($_GET['utm_source'] == "ww") {
        ?>
         ... javascript code here ...
        <?php
      }
   }
} // end function jr_add_floodlight_retargeting
add_action( 'wp_body_open', 'jr_add_floodlight_retargeting' );

But then, my code wasn’t firing properly, and I discovered that the child theme was old enough that it didn’t have the necessary code in header.php. I found out from this article:

WordPress 5.2 action that every theme should use

Added that code to the theme’s header file, and away I went! Yay.

A-PDF Thumbnailer

A-PDF Thumbnailer

We’ve been working on a project with lots of PDF files, and the download manager plugin makes use of featured images for the downloads. In the past, I’ve struggled with creating thumbnails of the first page… it had been a very time-intensive process.

Then, I found A-PDF Thumbnailer!! It made creation of the thumbnails really easy. After fiddling with it for a few minutes, I was able to create high quality, properly-sized thumbnails for a big batch of PDFs. And it’s quite a bargain at $27… it saved me hours of work.

You can download the trial version to see it in action before buying. It does even more than just creating thumbnails, but I haven’t needed to do that yet. Maybe someday. For Windows only.