0

I have inherited a WP site where some home page slides are pulled using

<?php   $po = get_posts( array('post_type' => 'page', 'meta_key' => 'Home Slide', 'order' => 'ASC', 'orderby' => 'menu_order', 'posts_per_page' => 5 ) ); ?>

The site owners want these slides changed but the Home Slide meta_key is not exposed in the UI.

I tried passing this to add a page (via the home page template).

<?php update_post_meta( 135, 'meta_key', 'Home Slide' ); ?>

And this to remove a page

<?php update_post_meta( 146, 'meta_key', '', 'Home Slide' ); ?>

But this did not appear to have any effect.

What is the correct way to either expose this in the UI or make changes/additions to it?

Also- these are sorted on menu_order. Does that mean that, as they are now, I need to re-order them in the site menu in order to change their order?

2 Answers 2

1

Go to the Page editor. Click the "Screen Options" box in the top right corner. In the dropdown, turn on the "Custom Fields" option. Now scroll down below the post editor area. Edit the fields as needed.

1
  • Hahaha. I like OO coding in PHP and Perl soooo much more than figuring out how WP does things. Thanks! Sep 18, 2014 at 21:58
0

Examining the postmeta table I found that meta_key is not the name of the key. The name is 'Home Slide'.

screenshot

So the correct calls would be

Adding this key:

<?php update_post_meta( 135, 'Home Slide', 'On' ); ?>

Removing this key

<?php update_post_meta( 146, 'Home Slide', '', 'On' ); ?>

Or just editing the rows in postmeta AFAICS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.