Category: Notes

  • Get a WordPress menu from a specific menu location

    Sometimes you know that you want a WordPress menu associated with a particular menu location, but you don’t know for sure which menu is associated with that location.

    To find out which menu it is (I typically want to know the slug) you can do something like the following.

    https://gist.github.com/nickdavis/25d4a733b7c2754ca1e34db31a735bb0


  • Right and left align menu items in a single container

    This technique will also preserve the order of your menu items. Whereas if you’d just floated some menu items to the right, the order of the right aligned items (if there were more than one) would now be wrong.

    Of course, this technique doesn’t just apply to menus but it seems to be the most common case I find for it out in the wild.

    [codepen_embed height=”265″ theme_id=”0″ slug_hash=”RpBwmE” default_tab=”html,result” user=”nickdavis”]See the Pen <a href=’https://codepen.io/nickdavis/pen/RpBwmE/’>Right and left aligned menu items in a single container</a> by Nick (<a href=’http://codepen.io/nickdavis’>@nickdavis</a>) on <a href=’http://codepen.io’>CodePen</a>.[/codepen_embed]

    Update (25 Mar 2017): Alain Schlesser (rightly) points out that this needs formatting for mobile. I should clarify that the above is only a proof of concept for a desktop view and I would re-format the layout for smaller screens (e.g. all centred, in a dropdown menu perhaps).

    In fact one of the bonuses of doing things this way is that you haven’t to create two different menus or extra containers within the menu to format things. So when it comes to mobile formatting you’ll hopefully have an easier time.


  • Get Post Slug in WordPress

    http://www.joshstauffer.com/get-post-slug-in-wordpress/


  • Add a comma after the testimonial name displayed by the Testimonials by WooThemes widget

    Depending on the settings you’re using in the widget, by default the widget’s output may read:

    Nick Davis iamnickdavis.com

    Instead this adds a comma after the name field and makes it more readable, like so:

    Nick Davis, iamnickdavis.com

    [gist id=”95025ffe1662f393f5065308a11b837e”]


  • NoIndex all posts in a WordPress category

    https://github.com/Yoast/wordpress-seo/issues/387#issuecomment-48589725


  • How to stop friends repeatedly adding you to Facebook Groups

    Recently a couple of ‘friends’ have added me to Facebook Groups without asking me first (thanks).

    You can of course just leave the group, but unfortunately some people just don’t get the message and will just add you again when they spam their friends list again a few days later.

    Now, of course, the most obvious way to stop this from happening is just to un-friend the person who is spamming you and they’ll no longer be able to add you to any groups.

    If you’re of a forgiving nature or don’t want to un-friend that person for whatever reason though, you can leave the group and prevent anyone from adding you back to it again.

    To do this, on your computer (I didn’t seem to get the option on mobile):

    1. Click Groups in the Facebook sidebar
    2. Then Groups (next to Discover in the top tabs)
    3. Scroll down to the group you want to leave
    4. Click the gear icon and then Leave Group
    5. Now the most important part, make sure you check the ‘Prevent other members from adding you back to this Group’ checkbox and click Leave Group.

    Stop friends adding you back to a Facebook Group

    Now you should be free from spam from that group at least.

    Knowing Facebook, all of the above will likely change in future and no longer work (please don’t come crying to me when it does), but hopefully it’ll help a few of you right now with this problem.


  • WordPress FTP access without login details (via a plugin)

    Sometimes I find myself in the situation where I need FTP access to a WordPress website and – although I have access to the WordPress admin itself – I don’t have the FTP login details for the website.

    Often this is because the person I’m helping is not sure how to get the FTP access details (or can’t easily get them) or maybe it’s urgent and there’s no time.

    In those circumstance I found this File Manager plugin useful. It gives you FTP access to the site but via the WordPress admin.

    There are also others available in the WordPress plugin repository, but this one has worked best for me from the ones I’ve tried (if you know of a better one add it in the comments!).

    Of course, this is very much a last resort or emergency option, but it’s good to have one.


  • Making viewport units (vh|vw|vmin|vmax) work properly in Mobile Safari

    https://github.com/rodneyrehm/viewport-units-buggyfill