Support » Plugin: Edit Flow » Get post editorial metadata

Viewing 1 replies (of 1 total)
  • Hi @vatavazz,

    The editorial metadata is stored the same way as any post metadata so it’s retrieved the same way using something like:

    get_post_meta($post_id, '_ef_editorial_meta_number_word-count', true);
    (substitute your own metadata fields for what I have in this example, _ef_editorial_meta_number_word_count, and of course true refers to a single value rather than an array)

    Here’s a page I setup that uses several editorial metadata fields to construct a list of topics from which logged-in authors can select to pitch:

    http://www.bestallinclusive.com/write-for-us/current-topics-list-submit-a-pitch/

    If you hover over the post title, you’ll see the description of what is wanted for that post (if there is one, the first two in the list don’t have that but others below should).

    And here is the code I used to create the loop that makes this list – note that I did this in my theme functions.php file to create a shortcode that I insert into the page content where I want that list to display:

    // Adds Shortcode to display topics list for writers, can use in content on writer's page
    add_shortcode( 'topicsList', 'display_topicsList' );
    function display_topicsList($atts){
    		$html= '<div class="topicsList">
    					<dl>';
    		$html.='<dt>Post Title</dt> <dd>Min Word Count</dd> <dd>Payment</dd> <dd>Status</dd>';
            $status = array('open','pitched','assigned');
    	    $args = array(
    		   'post_type' => 'post',
    		   'cat' => -660,
               'post_status' => $status,
               'posts_per_page' => -1,
               'ignore_sticky_posts' => 1,
    		   'orderby' => 'title',
    		   'order' => 'ASC'
           );
    	   		$the_query = new WP_Query( $args );
    			if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); 
                global $post;
    			$poststatus = ($post->post_status);
    			$post_id = ($post->ID);
    			$wordcount = get_post_meta($post_id, '_ef_editorial_meta_number_word-count', true);
    			$budget = get_post_meta($post_id, '_ef_editorial_meta_number_budget', true);
    			$description = get_post_meta($post_id, '_ef_editorial_meta_paragraph_assignment', true);
    			$subtitle = get_post_meta($post_id, 'post_sub_title', true);
    			
    			$html.= '<dt><a href="#" class="tooltips">' .get_the_title() . ': ' . $subtitle . '<span>' . $description . '</span></a></dt>';
    			$html.= '<dd>' . $wordcount . '</dd>';
    			$html.= '<dd>$' . $budget . '</dd>';
    			$html.= '<dd class="status-';
    			$html.= $poststatus;
    			$html.= '">';
    			$html.= $poststatus;
    			$html.= '</dd>';
    			
    			endwhile; endif;wp_reset_postdata();
    			$html.= '</dl>
    				</div>';
    			return $html;			
    }
    

    This is just one way to do it, also I am eliminating one category of posts from this query because we don’t allow non-staff authors to write posts for that category, but you can pretty much retrieve and display any metadata created by Edit Flow if you peruse your database to see what it uses for field names.

    Hopefully this will help you create something of your own, post back if you have more questions.

    Good luck!
    Trisha

    • This reply was modified 7 months, 3 weeks ago by  TrishaM.
Viewing 1 replies (of 1 total)
  • The topic ‘Get post editorial metadata’ is closed to new replies.