Title: Javascript get_posts
Last modified: August 21, 2016

---

# Javascript get_posts

 *  [po2368016](https://wordpress.org/support/users/po2368016/)
 * (@po2368016)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/javascript-get_posts/)
 * Is it possible to use the get_posts method in a javascript block?
    If yes, then
   how am I going to do it? Can anyone give me examples or links to get ideas.

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

 *  [marcelvanderhoek](https://wordpress.org/support/users/marcelvanderhoek/)
 * (@marcelvanderhoek)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/javascript-get_posts/#post-4595668)
 * You could use JSON to pass the resulting array from get_posts() from PHP to JavaScript:
 * `var posts = JSON.parse('<?php echo json_encode($posts_array); ?>');`
 *  Thread Starter [po2368016](https://wordpress.org/support/users/po2368016/)
 * (@po2368016)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/javascript-get_posts/#post-4595777)
 * Can you give me an example on how to do this sir?

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

The topic ‘Javascript get_posts’ is closed to new replies.

## Tags

 * [get_post](https://wordpress.org/support/topic-tag/get_post/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [po2368016](https://wordpress.org/support/users/po2368016/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/javascript-get_posts/#post-4595777)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
