Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* header menu */
- register_nav_menu("menu", "Main menu");
- /* footer menu */
- register_nav_menu("menu_footer", "Footer menu");
- /* thumbnails */
- add_theme_support('post-thumbnails');
- function my_get_post($post_id) {
- // Custom fields
- $ret['custom_fields'] = get_post_custom($post_id);
- // Content
- $content = get_extended(get_post_field('post_content', $post_id));
- $ret['content'] = [
- 'title' => get_the_title($post_id),
- 'main' => apply_filters('the_content', $content['main']),
- 'extended' => apply_filters('the_content', $content['extended']),
- ];
- $ret['content_free'] = [
- 'title' => get_the_title($post_id),
- 'main' => $content['main'],
- 'extended' => $content['extended'],
- ];
- // Images
- $ret['thumbnail'] = [
- 'thumbnail' => get_the_post_thumbnail_url($post_id, 'thumbnail'),
- 'medium' => get_the_post_thumbnail_url($post_id, 'medium'),
- 'large' => get_the_post_thumbnail_url($post_id, 'large'),
- 'full' => get_the_post_thumbnail_url($post_id, 'full'),
- ];
- // Media
- $thumbnail_id = get_post_thumbnail_id($post_id);
- $medias = get_attached_media('image', $post_id);
- foreach ($medias as $media) {
- if ($media->ID != $thumbnail_id) {
- $ret['media']['image'][] = [
- 'thumbnail' => wp_get_attachment_image_src($media->ID, 'thumbnail')[0],
- 'medium' => wp_get_attachment_image_src($media->ID, 'medium')[0],
- 'large' => wp_get_attachment_image_src($media->ID, 'large')[0],
- 'full' => wp_get_attachment_image_src($media->ID, 'full')[0],
- 'excerpt' => $media->post_excerpt,
- ];
- }
- }
- return $ret;
- }
- function my_get_posts($post_type = 'post', $cat_id = 0, $tag = NULL) {
- $ret = [];
- $args = array(
- 'numberposts' => -1,
- 'category' => $cat_id,
- 'orderby' => 'date',
- 'order' => 'ASC',
- 'include' => array(),
- 'exclude' => array(),
- 'meta_key' => '',
- 'meta_value' => '',
- 'post_type' => $post_type,
- 'suppress_filters' => true,
- 'tag' => $tag ? $tag : '',
- );
- $posts = get_posts($args);
- foreach ($posts as $post) {
- setup_postdata($post);
- $ret[$post->ID] = my_get_post($post->ID);
- }
- wp_reset_postdata();
- return $ret;
- }
Add Comment
Please, Sign In to add comment