Snippets.page

Code snippets, tips, how-tos

Tag: web dev

  • Fix HTML not working in Hugo

    By default, Hugo does not render HTML (and JavaScript). So you can’t use HTML tags in the markdown files. To enable this, change the following setting in config.yml: If your theme uses TOML or JSON, you can get instructions for these here. Shortcode to open links in new tab If HTML rendering is enabled in […]

    Read more

  • Change the footer in WordPress admin

    To change the footer text in the WordPress admin area, add the following lines to your theme’s functions.php. To remove the version number on the right side of the footer, you need to remove the existing text and then add the new text.

    Read more

  • Run multiple versions of PHP in XAMPP

    Download the required version of PHP from https://www.php.net/downloads.php. For PHP7+, you can download the Thread Safe version. For older PHP, try the Non Thread Safe version. Create another folder in C:\xampp for this version of PHP apart from the existing C:\xampp\php. E.g., C:\xampp\php74. Copy the downloaded version’s files into this folder Create php.ini in this […]

    Read more

  • Overflow both sides in CSS

    Normally, when content or an image overflows outside a div, the overflowing content is shown on the right outside the “box”. If you want to position the content to the center, so that overflow is on both sides, you can use this class. This is useful to position an image such that the centre of […]

    Read more

  • Make an inner div full width in CSS

    Make an inner div expand to the full-width of the page. When a div is inside another div, adding width: 100% will only stretch it to the width of its container. To make the stretch to the full width of the page (or viewport), use this:

    Read more

  • Add custom post types to WordPress search

    Include custom post types in the search using WordPress hooks To include custom post types in the default search, we need to modify the search function using an action hook. Post types that we want to search through are added to the search query in an array. The array needs to include WordPress’s default post […]

    Read more

  • Align second line of bullet points in CSS

    HTML aligns the lines after the first line flush with the bullet point (the dot) instead of the text. You can fix this with the class below. text-indent property applies only to the first line of a text-block. So we first “pull” the first-line back along with the dot. Then we push the entire text-block […]

    Read more

  • Highlight the current post’s tags in WordPress

    List all tags in a bulleted list and highlight only the current post’s tags. Highlight the current post’s tags using CSS The idea is to show all the tags used on the site and then add a CSS class to the tags that are used in the current post. This class can then be styled […]

    Read more