WordPress.org

Ready to get started?Download WordPress

Forums

Types - Custom Fields and Custom Post Types Management
Use function to display custom fiel (3 posts)

  1. pxforti
    Member
    Posted 2 years ago #

    I am trying to use a function to display custom field, but nothing shows. I can display the field if I insert the echo code directly in the page template.

    With function below, the paragraph and text "tt" show up, but no field data. Does your plugin get added to wordpress post meta?

    function movie_director($content) {
    	global $post;
        $director = get_post_meta($post->ID, 'directors', true);
        if ( 'movies' == get_post_type() )	{
        return $content . '<p>' . $director . 'tt</p>';
        } else	{
    	return $content;
       }
    }

    http://wordpress.org/extend/plugins/types/

  2. helgatheviking
    Member
    Posted 2 years ago #

    you must add your movie_director function to a hook or a filter for it to do anything.

    add_filter('the_content','movie_director');

  3. pxforti
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.