Mary Dickson Diaz

Code, Life, Learning

Tag: wordpress

how to use the wordpress rest api in rails

Folks, if you’re reading this over at www.marydickson.info, my Rails portfolio site, things are about to get real meta. Several weeks ago I RSVPed for a WordPress Developer’s meetup called Introduction to the REST API. I’ve used APIs with Rails, Angular, and in Twitterbots– an API (application program interface) is simply a way to transfer information from a server to a client, often using a format called JSON (JavaScript object notation). APIs are key to mobile apps that access the same database as a web based site. “REST” (representational state transfer) means that a system understands a set of standard verbs used to communicate over HTML, including: GET, POST, PUT, DELETE, etc. You can use an AJAX (asynchronous JavaScript and xml) call to transmit data via the REST verbs and either fetch data, post new data, update existing data, or delete a record, and the information will be persisted in a database somewhere behind the scenes.

That’s a lot of acronyms. Here have a picture:

how APIs work, sort of

Super! MARY, BUT WHY SHOULD WE CARE?

Long story short: I’ve had this WordPress blog since I started coding, and since then I’ve coded other web sites “from scratch,” including a professional portfolio site, that are much easier for me to customize and that add legitimacy to my claim of web developer. So that is what I want to share with potential employers but I also want them to see my awesome technical blog posts so they will think “She sounds cool and writes good. Let’s pay her money in exchange for her time!” UNTIL NOW the way to do that was to direct people to this site, marydickson.com, and hope that they will also go check out marydickson.info, or vice versa. Awkward.

The WordPress API allows me to import blog posts from marydickson.com and render them as a tab on marydickson.info. If you have any sort of non-WordPress site and you’d like to link to or display your blog posts, you can do that with the WordPress REST API. I’ll walk you through what I did to get this working in a Rails app:

Continue reading

you might be using pingbacks wrong if…

You all know about pingbacks, right? It’s a tool for seeing when other websites are linking to your content. Used correctly, they help facilitate a dialogue between two pages/people, build friendships, end war, etc.

Except… here on my page, it’s exclusively a conversation with myself where I am regularly sent emails asking if I want to approve my own links on the site. And usually I’m like, sure, she seems trustworthy, she is the *sole admin and contributor* so that’s probably ok. There’s no way to “pre-approve all links from this site to this site” so I’m stuck doing it on a case by case basis, leaving these weird pingback links that I don’t want or need. All along I’ve thought “this can’t be right” but only recently figured out how to fix. It is *not* intuitive, as I will attempt to show you here as I rain down shame upon WordPress, but it is also an easy fix.

The WordPress user interface for linking to content on your own site is deliberately (?) deceptive.

So what happens is that anytime I link to content on this page, let’s say I want to send you to my page about bots, I click the word “bots” and the following screen pops up:

Screen Shot 2015-07-27 at 8.53.40 AM

See how it helpfully has a “link to existing content” section? So that’s what I’ve been using. Let’s look for bots and find my page (or post or whatever)…

Screen Shot 2015-07-27 at 8.54.02 AM

And…. done! So what happens now is that I get an email saying “A new pingback on the page “bots” is waiting for your approval from Website: Mary Dickson Diaz. Options: Approve it, Trash it, Spam It. Please visit moderation panel.” And I have to click “yes, approve it” because the site is treating it exactly the way it would handle a real pingback from an external site (if someone wants to give me a pingback to test this out, that would be rad) or a new commenter. And THEN once I hit approve, it adds a little comment-type remark on the bottom of the page with a note that the content’s been linked to elsewhere.

Obviously I don’t want to go through all that, right? That’s overkill when I just wanted to link you to my stupid page about bots.

INSTEAD… what you can do to get the page to make an internal, relative link instead of an absolute link (which sets the wheels in motion for a pingback) is to do exactly what I did in the steps above, but then remove the “http://www.yoursite.com”. Keep the backslash in front of your post link. Like so:

Screen Shot 2015-07-27 at 8.54.30 AM

I like to open links in a new tab because I am notorious for clicking down rabbit holes and forgetting how I got there and what I was trying to do in the first place.

So simple! Why isn’t this part of the standard user interface? Why did I have to google all that to figure it out? These are questions I have for you, WordPress, ruiner of inboxes.

HUGE DISCLAIMER

I don’t know a lot about migrating website content. I do know that how you link to internal pages can make life easy or difficult if you later decide to change the structure of your page (let’s say I decide I want everything here to live in marydickson.com/blog instead, or I change my domain name to marydicksondiaz.com). I believe that relative vs. absolute linking is almost always the best way to go, but others can chime in if I’m wrong.

Better links, cleaner site, less email. What could go wrong?

Oh.

on wordpress and websites

Blogging to you live from ye olde custom internet domain! Let’s get meta here for a minute.

Basic knowledge of HTML/CSS is important for more advanced learning in coding and software development. I used to know my way around angle brackets back in my Blogger days, but I’m rusty (real talk: is it still blogging if it comes from WordPress or should it be referred to as “pressing” now?). While the first few posts on this site were created on a wordpress.com hosted site (marydickson.wordpress.com), I had always planned to migrate over to a dot com of my own, setting up a page that could get me started and documenting right away, while still allowing for more advanced customization and scaffolding down the road.

Shockingly, myname.com was available, so I snatched it up via Namecheap, who I know from my time working with Fight for the Future are big supporters of internet freedom issues. The cost to register and host marydickson.com for a year was $9.66  and $9.88, respectively.

Continue reading

© 2023 Mary Dickson Diaz

Theme by Anders NorenUp ↑