Skip to content

From Magic Fields 1.x to ACF, Part 5

Other posts in this series: Part 1; Part 2; Part 3; Part 4; Part 5 (this post); Part 6;Part 7; Part 8; Part 9

On one of the multisite installations I manage, I’d also set up a sub-site with Magic Fields. This one is for an inventory of churches in the Archdiocese of Newark. The scholar who did the research sourced out the buildings’ dates, pastors, window designers, bell foundries — a lot of detailed information. Plus photos, interior and exterior.

And besides Magic Fields needing to go away, it’s using a non-responsive theme. That’s a mandate around here.

The good news is that there aren’t any relationship fields to deal with. Everything is straight-up postmeta information. I might not even need to do a custom post type. If I can get away with a simple child theme I’ll be a happy camper.

Biggest Problem

Magic Fields was (apparently) not designed with multi-site in mind. The write panels and fields are stored in global tables, not a specific per-blog tables. Not only that, but you can’t initiate it anymore on a new blog (at least, version!

Fatal error: Uncaught Error: Call to undefined function mysql_query() in /path/to/wp-content/plugins/magic-fields/RCCWP_Application.php:15
Stack trace: #0 /path/to/wp-content/plugins/magic-fields/RCCWP_Application.php(263):
RCCWP_Application::AddColumnIfNotExist(‘wp_95_mf_module…’, ‘expanded’, ‘tinyint after d…’)
#1 /path/to/wp-content/plugins/magic-fields/RCCWP_Application.php(235): RCCWP_Application::UpgradeBlog()
#2 /path/to/wp-includes/class-wp-hook.php(287): RCCWP_Application::Install(”)
#3 /path/to/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array)
#4 /path/to/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#5 /path/to/wp-admin/plugins.php(179): do_action(‘activate_magic-…’)
#6 {main} thrown in /path/to/wp-content/plugins/magic-fields/RCCWP_Application.php on line 15

Which is just as well, because I suspect that if I could do a new activation then that activation would have access to all of the fields and field groups, enabling another user to really damage the original blog. I’m guessing here.

Working Version

In parts 1 to 4 of this series I worked on a single blog on a shared hosting platform. It was a stupendous pain in the butt to make a replica so that I could work on it without bringing the live site down. On WordPress multisite I have to say it’s stupid easy. The MultiSite Clone Duplicator is one of my favorites. I can clone any site either from the dashboard, or from the command line with it’s CLI tool.

So word to the wise, clone the site you want to rebuild and work on that. When it’s time to go live just change the paths in the Edit Site network dashboard and the change takes place instantly.


The child theme I’d developed in 2010 for this blog reflects my ignorance as well as the state of the art ten years ago. And since the parent theme has to go (I’d already network-disabled it for any other sites) anyway I’m going to start fresh with another theme. The individual pages are set up with a wide sidebar for a featured image and a few of the important custom fields. But that get_sidebar() function and it’s attendant styling are what’s preventing the pages from being responsive.

The sidebar had been called by the get_sidebar() function, which pulled in the sidebar.php template. That template was hard-coded to pull in the featured image, and a few of the custom fields. As we saw in a previous episode, that functionality can be put into a widget.

However, that sidebar widget will get pushed to the bottom on a mobile device. But that’s what we want people to see as highlighted content, so we need a way to push the sidebar up to the top on smaller screens.

After looking through our selection of themes (I’m the root user of this blog, so I can install any theme I need to. But I’m pretty sure I’ve got one that will work). Let’s see:

Dara: Nice enough, but the post headers obscure part of the featured image. I can restyle it to be translucent, but it’s still partially obscuring it.

Sixty: Treats the header well, but doesn’t seem to cooperate on my missing to push the sidebar to the top.

Clean Retina: Maybe OK, but a little busy.

Period: Bingo. Nice wide sidebar, easy to manipulate code. I’ll start working with this one.


I’m going to start with the widget, using the same basic code found here. Remember to start it with a <php. Create a folder in /wp-content/plugins, and save the file as a .php into that folder.

And then once I have that, add something to the style.css so that the sidebar floats to the top on a mobile device. You can find a really simple method here. This is the custom CSS I loaded into the customizer, to use with my Period child theme:

@media only screen and (max-width: 900px) {
body.single #primary-container .max-width {display:table;}
body.single #primary-container section#main {display:table-footer-group; float: none;}
body.single #primary-container aside {display:table-header-group; float: none;}

Here's where we are so far:

Custom Fields

Custom fields are why we're here, right? Let's dig in. For my purposes I only need to change how the single post template functions. Oftentimes it's called "single.php," but in the Period theme it's called "content.php" and it's saved at the top level of the theme directory. I'll make a copy from the original (/themes/period/content.php) into my child theme folder (/themes/period_copy/content.php) and start digging in.

First, I want to know that all the fields are being captured. I'll just drop this into the file right below the_content();

echo 'Name of Parish: ' . get_field('name_of_parish') . '<br />';
echo 'Date of Establishment: ' . get_field('date_of_establishment') . '<br />';
echo 'Founding Pastor: ' . get_field('founding_pastor') . '<br />';
echo 'Ethnicity: ' . get_field('ethnicity') . '<br />';
echo 'Architect: ' . get_field('church_building_architect') . '<br />';
echo 'Architectural Style: ' . get_field('church_building_architectural_style') . '<br />';
echo 'Interior Designer: ' . get_field('church_building_interior_designer') . '<br />';
echo 'Fabricator of Windows: ' . get_field('church_building_fabricator_of_windows') . '<br />';
echo 'Bells: ' . get_field('church_building_bells') . '<br />';
echo 'Specific Notable Works of Art: ' . get_field('church_building_specific_notable_works_of_art') . '<br />';
echo 'Renovations: ' . get_field('church_building_renovations') . '<br />';
echo 'Current Status: ' . get_field('church_building_current_status') . '<br />';
echo 'Current Owner and Use: ' . get_field('church_building_current_owner_and_use') . '<br />';
echo 'Interior Pictures: ' . get_field('church_building_interior_pictures') . '<br />';
echo 'Exterior Pictures: ' . get_field('church_building_exterior_pictures') . '<br />';
echo 'Commentary: ' . get_field('church_building_commentary') . '<br />';
echo 'Year Opened: ' . get_field('church_building_year_opened') . '<br />';
echo 'Year Closed: ' . get_field('church_building_year_closed') . '<br />';

Then test-drive a few pages. For the most part, everything works right out of the box -- without any database manipulations yet. But there are a few issues. Architect, Architectural Style, Fabricator of Windows, Bells, Notable Works of Art, Renovations, and Interior Designer are multiples; only the first (or the last) is showing, and we'll need to group those all together. And the pictures selections, which are groups, only display a single filename.

Name of Parish: Our Lady of Sorrows
Date of Establishment: 1914
Founding Pastor: Msgr. Ernest J. Monteleone
Ethnicity: Italian
Architect: Anthony J. DePace
Architectural Style: Romanesque Revival
Interior Designer: Felix Lanzaroni - marbles
Fabricator of Windows: Rivell
Specific Notable Works of Art: The interior marbles are by Felix Lanzaroni. The sculptors were Rochette and Parzini 1940 - Copy of Michelangelo's Pieta. A single block of white Carrara marble was sculpted by Trevi Studios of Rome, Italy.
Current Status: In use
Current Owner and Use:
Interior Pictures: jc.ols.interior01.jpg
Exterior Pictures: jc.ols.exterior02.jpg
Year Opened: 1935
Year Closed:

As we recall from our earlier expeditions, Magic Fields stores each of these multiple entries in a separate row in the database, while ACF puts them into a serialized array. And in fact, I'd set them up wrong from the beginning.

Insert Car Crash Noise Here

Actually ACF only stores relationship fields in a serialized array. Any other kind of field (text, for example) you can only do one of each. MF has multiples built right in. In order to do it in ACF I need to buy the Pro version. Not that I'm cheap or anything (I could get the U to pay for it) but I'm trying to something that works easily for everyone.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    Share This