Title: Grabing the content?
Last modified: August 19, 2016

---

# Grabing the content?

 *  [yeyeman9](https://wordpress.org/support/users/yeyeman9/)
 * (@yeyeman9)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/grabing-the-content/)
 * What is the php code to grab the content of the post? I want to put it for a 
   meta tag:
 * `<meta property="og:title" content="" />`
 * it will go where it says content=”” but I am not sure what to put there. I have
   tried <?php the_content() ?> and even <?php echo $post_data->post_content) ?>
   but nothing seems to be working.
 * So bascially what is the php code to grab the content from a post? This will 
   go in the header….Or perhaps thats the problem? That it should go in the header.
   php?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Clayton James](https://wordpress.org/support/users/claytonjames/)
 * (@claytonjames)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/grabing-the-content/#post-1852958)
 * > What is the php code to grab the content of the post?
 * I think that might have to run from inside the loop to work.
 * [edit] some references: [http://codex.wordpress.org/Meta_Tags_in_WordPress](http://codex.wordpress.org/Meta_Tags_in_WordPress)
   
   there is an interesting section in that one on a “conditional tag query”.
 * [http://codex.wordpress.org/The_Loop](http://codex.wordpress.org/The_Loop)
 *  Thread Starter [yeyeman9](https://wordpress.org/support/users/yeyeman9/)
 * (@yeyeman9)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/grabing-the-content/#post-1852962)
 * Solved nevermind! thanks!
 *  Thread Starter [yeyeman9](https://wordpress.org/support/users/yeyeman9/)
 * (@yeyeman9)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/grabing-the-content/#post-1852965)
 * Here is what I did, for anyone that might need some future reference:
 *     ```
       <?php foreach($posts as $post): ?>
   
       <?php $post_data = get_post($post->post_id, OBJECT); ?>
   
           <meta property="og:title" content="<?php echo $post_data->post_content ?>" />
   
       <?php endforeach; ?>
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Grabing the content?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [yeyeman9](https://wordpress.org/support/users/yeyeman9/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/grabing-the-content/#post-1852965)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
