Tag Archives: custom metabox

Long weekend of pizza and coding

This past week/weekend has taught me a lot about the world of coding — hours can fly by without you realizing it. However, that doesn’t necessarily mean that you’re completing numerous tasks…you could have gotten no where. For a few hours on Saturday, as I coded with a few classmates, that’s how I felt. That I had done so much work customizing my WordPress site, but was not getting the results I was hoping for. For example, I finally had success creating a custom post type (YAY!!), but after creating the meta boxes (following the guidelines of the Reading List example Greg showed us in class), the meta boxes weren’t working. The information was not being echoed correctly, or at all. That was infuriatingly frustrating. Today, it’s still not working. After putting that to the side, I worked on creating two other custom post types, had written all of the code and was ready to conquer these additional post types (TV Review & Restaurant Review). To no avail, I realized that WordPress doesn’t allow for multiple custom post types. Even after hours of Googling the answer, I haven’t been able to figure it out. Any help is appreciated!

Update on my final project site:

  • I’ve created three custom post types with meta boxes as plugins. They don’t work properly, but i’ve created them.
  • I’ve updated the CSS of the child theme as much as I could to my satisfaction for the layout/display of the site. I incorporated Google fonts, HEX colors, and updated the main menu navigation.

What’s left to do:

  • Continue working on getting the custom post types and meta boxes to work!
  • Adding two plugins: Instagram feed and Contact form
  • Inserting content

The next few days should be interesting. I am really hoping to be able to get the customizations I set out to do done and to successfully complete the project. Below are a few questions I have:

  • How do we add multiple custom post types?!
  • how do we get our meta boxes to echo the information we put in them?

Big shout out to Allie, Jaclyn, and Lucy for all their help this weekend!

Custom Post Metaboxes and Styling My Site

I spent most of this week working on creating a custom metabox and custom fields for my site. As I mentioned in last week’s post, I created a custom post type plugin to log all of my runs. I was able to create a custom metabox called “run details” with three fields — neighborhood, date, and time. However, I’ve been unable to get the data that I enter into the custom fields to save and echo out to my post type. I even rewrote my custom post type plugin according to the reading list example Greg showed us, but haven’t been able to get the data to save. So I now have two versions of the same plugin written in different code, but both have the same issue. I spent more than five hours troubleshooting this on Friday night, but to no avail. For now, I’ve moved onto styling my child theme in CSS. I did figure out how to get my custom posts to show up on my homepage, which was one of the questions I had last week.

I played around with adding this Strava plugin to my site, but the reviews for this plugin mentioned that it is not mobile-friendly. I confirmed this fact when I downloaded and installed the plugin, created a test post using the suggested shortcode, transferred the files to my live site using FileZilla, and then pulled up that specific post on my phone. The reviews were (sadly) correct — the table showing the data about my run bled out of the area of my post, and looked really bad. Because there are very few Strava plugins out there, and because this flawed plugin was the highest-rated and most often downloaded one, I decided to instead use the shortcode provided by Strava to insert a text widget into the main sidebar of my site. I did this on my local site to see how it would look, and then went ahead and added the text widget to my live site. I know this doesn’t count as a code modification, but having my Strava account linked in some way to my site was a very important part of my project. Perhaps the addition of this widget can count under the “content” grading criteria instead.

I’m likely going to have to abandon my plans to create a lightbox photo gallery due to the fact that I’m running out of time to work on this project, but I’m still hoping to build a featured post carousel onto the homepage of my site. I’ll also be writing some content so that I can have at least five posts on my live site.

I’ve been loading my plugin and theme files onto my live site via FileZilla. It’s so exciting to see my changes show up on my live site. I did have a minor snafu when using the FTP server the other night. Something happened when I was replacing my CSS file, and when I refreshed my live site, all of my styles had disappeared and my site was showing up in Times New Roman with bulleted lists. I may or may not have cried for a few minutes. I had to delete my child theme files from the remote server and then re-upload them using FileZilla, and that fixed the issue. Crisis averted. I’m hoping not to have any more scares like this before the August 6 project due date!

Finished Final Project

Looking back at my final pitch last night, I am happy to say that I was able to make pretty much all of the customizations I set out to in my final project. In addition to creating a site with sections for my resume, writing, and blog, I created a custom post type with custom fields and meta boxes, used one plugin to add a rotating gallery to my front page, and used another to add an interactive poll to my blog.

My most complicated customization was definitely my custom post type, i.e. the bane of my existence for the past two weeks. It took me a long while to figure out how to make the data in my custom meta boxes echo out in the post. I finally did it by creating separate single.php and archive.php files for my custom post type but had to spend several days Googling and searching the internet before a couple of forums pointed me in the right direction. Once I was able to get the data on the page, I hit another snag when it came to trying to style it. No matter what I did in CSS, my meta boxes wouldn’t change in appearance (and all I wanted was to move them down a few spaces) so I ended up adding spaces in the actual PHP code as a kind of work-around solution. Overall, my custom post type turned out pretty well, although I am still having trouble getting it to appear in the “archive” and “recent posts” section of my blog. I will look more into this to see if I can figure out a solution before Wednesday.

Because I used plugins, both the gallery and poll were fairly easy to implement – the most difficult part for each was figuring out what code I needed to insert in what document to get the features to show up where I wanted them to. Overall, both features look good and work well, except for the poll, which seems finicky for some reason. I tested it multiple times and sometimes it let me vote and sometimes it would just get stuck on showing me the results page, not letting me vote again. I plan to look into this as well.

I’m interested to see everyone else’s sites and customizations and to see what feedback I’ll get about my code. I definitely know it’s not perfect and am looking forward to making any changes that can make my site better.