Skip to content

WordPress

Created: 2017-02-16 21:59:27 -0800 Modified: 2020-03-22 15:40:59 -0700

  • You shouldn’t usually have to touch the source code at all. For example, I wanted the sidebar to have a link for the description, so I went to Appearance → Widgets → Text and added it. Getting the styling was kind of annoying, but Appearance → Editor can let you modify the CSS directly.
  • The blog’s description is what’s used in the <meta> tag for the description, so don’t try putting links in there or anything.
  • I believe a “partial” is a piece of templated code that has to be called in order to show up on the page (reference).
  • If there’s a default function you ever want to override, call add_filter(‘name_of_existing_function’, ‘name_of_your_override’);, then make sure to define “function name_of_your_override() {}” somewhere.

I use Cpanel’s Softaculous to manage this for Bot Land.

EZ PZ: just install https://wordpress.org/plugins/all-in-one-wp-migration/

Then I exported to a file and I was done (I mean, I also exported the database just in case since that at least has the contents of my posts).

I also deactivated the plug-in after doing that (just in case it does anything other than allowing exports).

Here’s a quick version of what I did originally (reference), which is garbage (because it’s fragmented into many steps, it’s incomplete, and wp-content has like 800 individual downloads even for a small blog):

  • Export the database via cPanel (I just used the quick export)
  • From the WordPress admin panel itself, go to Tools → Export → All content.
    • This just gives an XML file with none of the images.
  • Use FTP to download all of “wp-content”.

Modify functions.php to include this (I put it at the bottom):

add_filter( 'get_custom_logo', 'override_with_my_logo' );
function override_with_my_logo() {
$custom_logo_id = get_theme_mod( 'custom_logo' );
$html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
esc_url( 'www.example.com' ),
wp_get_attachment_image( $custom_logo_id, 'full', false, array(
'class' => 'custom-logo',
) )
);
return $html;
}

I installed an extension for this called “Scroll to Anchor” (reference), so now I just have to add this to my headers:

Introduction [sta_anchor id=“intro” /]

There’s an ⚓ icon that lets me add these. After that, I link to the anchors by making a link to #intro.

Note that I do not get the 🔗 icon next to the headers so that people can figure out how to link to them directly by themselves.

Consider having permalinks with the post title in them, that way they’re more obvious what they’re about when linked in other sources (social media, search engines, etc.)

I ran into an issue where I pointed bot.land at CloudFront to host static content for the landing page. In doing so, I removed the old DNS A record that pointed bot.land at my shared host (which had WordPress installed). Some content loaded, but most of it failed due to links starting with something like this:

https://bot.land/blog/wp-content/

The problem is that “bot.land” points to CloudFront. It’s blog.bot.land that points at the WordPress content. I needed to get WordPress to load everything using blog.bot.land instead of bot.land/blog.

I did some investigation into the PHP and I found out that index.php loads wp-blog-header.php, which loads wp-load.php, which defines ABSPATH as “/home/botland/public_html/blog/“. This was all a red herring though, the real solution is below.

I went to PHPMyAdmin and downloaded a copy of my database. Then I changed the two instances in the wppb_options table that had “http://bot.land/blog” to “https://blog.bot.land” (I got the idea from here). That got the homepage to load and be themed correctly, but all of the posts/comments were still broken.

E.g. this link used to work on the old one: https://bot.land/blog/2016/10/being-a-development-streamer-on-twitch/

This link now doesn’t work: https://blog.bot.land/2016/10/being-a-development-streamer-on-twitch/

To fix that, I used this resource; I just had to log in to the admin panel (which involved resetting my passwords for some reason), then go to Settings —> Permalinks —> Save changes (without actually making any changes).

If you can’t make a post or something that you think you should be able to do, then it’s possible that roles got messed up somehow. Just log in as an administrator and change the role of a particular user to something like “Contributor” or “Author”.

If you find yourself having to reset your password more than once even though you’re sure you’re using the correct password, then you may have run into what I stupidly ran into for months. When you reset your password, Wordpress generates a new one for you, but you have to click “Reset” for it to actually take effect. What I’d been doing was to get to that screen but never actually persist the new password.