I've the next function that I have put into my functions.php file in WordPress. The concept is it gathers all the game titles of 'fsmodel' posts (a custom publish type that I have produced). After that it returns these being an array, that we then use to populate a choose tag within the custom meta fields for any second custom publish type.

Essentially, 'fsmodel' may have posts having a boat model, and also the 'fsboat' publish type may have a drop-lower using the names of each one of the models to choose from.

Now, this seems to works fine within the Dashboard - the drop-lower is populated not surprisingly. After I save, however, the publish does not display in the Edit list. Also online, all pages output because the 404 error page if this function is active.

I am sure that the issue lies inside the following code - does anybody have idea things i may have done wrong?

function fs_model_array() Wordpress_Query(array(

    'post_type' => 'fsmodel',

    'posts_per_page' => -1,

    'orderby' => 'title',

    'order' => 'ASC',

    'post_status' => 'publish'


while ( $loop->have_posts() ) : $loop->the_publish()

$models_array[] = get_the_title()


return $models_array

It has been requested lately. Click here to determine exactly what the experts need to say. Best of luck :)

OK, I have develop an answer (I really hope - it's supporting for the time being).

Rather than developing a loop, I have used just the $wpdb->get_leads to search the database for that column having a WHERE filter for that custom publish type.

Then run an assortment builder:

$models_array = array()

$model_db = $wpdb->get_results("Choose publish_title FROM $wpdb->posts WHERE publish_type='fsmodel' AND publish_status = 'publish'")

foreach ($model_db as $model_db) 

Many thanks for the time, hsatterwhite! :-)

I believe you will probably find that adding wp_reset_query() towards the finish of the function will solve your problems :)

however , you're invoking the wordpress loop in a strange place or perhaps a place that already includes a loop going)?