/** * * Get the content for posts * */ public function getPostContent($params = array()) { $content = ''; // Initiate shortcode query builder class $shortcodeQuery = new Runway_ShortcodeQueryBuilder(); $wp_query_args = $shortcodeQuery->getQueryParams($params); if (!$wp_query_args) { return; } // Make sure we get all queried items $wp_query_args['posts_per_page'] = -1; // make new query based on shortcode $the_query = new WP_Query($wp_query_args); if ($the_query->have_posts()) { // Get posts and content // ------------------------------------------------------------------ // Loop through the results and print each. while ($the_query->have_posts()) { $the_query->the_post(); $linkTitle = esc_attr(sprintf(__('Permalink to %s', 'framework'), the_title_attribute('echo=0'))); $excerptLength = isset($params['excerpt_length']) ? $params['excerpt_length'] : 20; $id = get_the_ID(); $content[$id] = ''; // Thumbnail image if (has_post_thumbnail()) { // Get the image data $image['post_id'] = $id; if (isset($params['image_size'])) { $image['image_size'] = $params['image_size']; } // Retrieve the resized image $thumbnail = $this->getResizedImage($image); // see if we have any content after the image $hasContent = ''; if (isset($params['hide_title']) && $params['hide_title'] == 'true' && (!isset($params['post_excerpts']) || empty($params['post_excerpts']))) { $hasContent = 'no-content'; } // Build the image container $content[$id] .= '<div class="featured-image ' . $hasContent . '" data-image="' . esc_url($thumbnail['large_image']) . '">'; $content[$id] .= '<a href="' . get_permalink() . '" class="styled-image ' . get_post_format() . '" title="' . $linkTitle . '" rel="bookmark">' . $thumbnail['full_image_tag'] . '</a>'; $content[$id] .= '</div>'; } // Post title if (!isset($params['hide_title']) || $params['hide_title'] !== 'true') { $content[$id] .= '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . $linkTitle . '">' . get_the_title() . '</a></h2>'; } // Post content if (isset($params['post_excerpts']) && !empty($params['post_excerpts'])) { $content[$id] .= '<div class="entry-content"><p>' . customExcerpt(get_the_excerpt(), $excerptLength) . '</p></div>'; } } } // Clean up unset($the_query); unset($wp_query_args); wp_reset_postdata(); return $content; }
<a class="block" href="<?php the_permalink(); ?> "><h3 class="font-600"><?php the_title(); ?> </h3></a> <p class="info-text"><?php the_time('M d, Y'); ?> </p> <p><?php echo customExcerpt(150, '...'); ?> </p> <a href="<?php the_permalink(); ?> " class="button primary">Read More »</a> <br><br><br> </div> <?php } } else {
" height="<?php echo $image['height']; ?> " alt=""> </figure> </div> </a> <div class="blog_scroll-text"> <h2><?php the_title(); ?> </h2> <p class="text"><?php echo customExcerpt(get_the_excerpt(), $excerpt_length); //echo substr(get_the_excerpt(), 0, 360) ?> </p> <p class="readmore_arrow"><a href="<?php the_permalink(); ?> "><?php echo $read_more; ?> </a></p> </div> </div> <?php }
function shortcode_simple_content($atts, $content = null) { extract(shortcode_atts(array('post_id' => false, 'hide_title' => false, 'post_excerpt' => false, 'excerpt_length' => false, 'button_text' => false, 'image_position' => 'image_top'), $atts)); global $Runway_ContentRotator; $class = 'simpleContent'; // get post if (!$post_id) { return __('Please enter a post id in the simple content short code.', 'framework'); } $new_query = new WP_Query(array('p' => $post_id)); if ($new_query->have_posts()) { $new_query->the_post(); $title = ''; $button = ''; $img = ''; if (!$hide_title) { $title = '<h2>' . get_the_title() . '</h2>'; } if (str_replace(array("'", '"'), "", trim($button_text)) != "-1" && !empty($button_text)) { $button = '<a class="btn small" href="' . get_permalink(get_the_ID()) . '">' . $button_text . '</a>'; } $class .= " " . $image_position; if (has_post_thumbnail(get_the_ID())) { $thumb_size = $image_position == 'image_left' ? '228x186' : 'big'; $image = $Runway_ContentRotator->getResizedImage(array('post_id' => $post_id, 'image_size' => $thumb_size)); $img .= '<div class="image">'; $img .= $image['full_image_tag']; $img .= '<div class="image-overlay"></div>'; $img .= '</div>'; } $content = wpb_js_remove_wpautop(get_the_content()); // fix unclosed/unwanted paragraph tags in $content $content = customExcerpt($content, $excerpt_length); $box = '<div class="' . $class . ' clear">'; $box .= $img; $box .= '<div class="textContent">'; $box .= $title; $box .= '<div class="theText">' . do_shortcode($content) . '</div>'; $box .= $button; $box .= '</div>'; $box .= '</div>'; } else { return sprintf(__('There is no post with the ID %d (simple content short code)', 'framework'), $post_id); } wp_reset_postdata(); return $box; }
<?php } ?> <li class="post-info-last"> </li> </ul> <?php } ?> <?php if ($blogOptions['excerpt_length'] != -1) { ?> <p class="text"><?php if (isset($blogOptions['use_excerpt']) && $blogOptions['use_excerpt']) { // display the excerpt echo customExcerpt(get_the_excerpt(), $blogOptions['excerpt_length']); //echo implode(" ", array_slice(explode(" ", get_the_excerpt()), 0, $blogOptions['excerpt_length'])); } else { // display the full text the_content(__('Read more', THEME_NAME)); //echo get_the_content(); } ?> </p> <?php } ?> <?php if (isset($blogOptions['category_list']) && $blogOptions['category_list']) { ?>
function theme_post_content($post_id = false, $content = false, $excerpt = false) { global $post, $custom_query, $portfolio; $post_id = $post_id ? $post_id : $post->ID; $post_type = get_post_type($post_id); $postExcerpts = get_options_data('blog-options', 'post-excerpts', 'false'); $postExcerpts = $postExcerpts == 'true' ? true : false; $excerptLength = get_options_data('blog-options', 'excerpt-length', false); $readMore = get_options_data('blog-options', 'read-more', -1); $readMore_Exclude = array('quote', 'link', 'image'); // post formats to exclude read more link $fromShortcode = $custom_query ? true : false; // Check for setting overrides by a shortcode query if (isset($custom_query)) { $customPostExcerpts = isset($custom_query->query['post_excerpts']) ? $custom_query->query['post_excerpts'] : false; $postExcerpts = $customPostExcerpts && !empty($customPostExcerpts) && $customPostExcerpts !== 'false' ? true : false; $customExcerptLength = isset($custom_query->query['excerpt_length']) ? $custom_query->query['excerpt_length'] : false; if ($customExcerptLength && !empty($customExcerptLength)) { $excerptLength = $customExcerptLength; } $customReadMore = isset($custom_query->query['read_more']) ? $custom_query->query['read_more'] : false; if ($customReadMore !== false && !empty($customReadMore)) { $readMore = $customReadMore; } } if (!is_single() && ($postExcerpts === true || is_search()) || is_single() && $fromShortcode && $postExcerpts) { ?> <div class="entry-content summary"> <?php $excerpt = get_the_excerpt(); // Excerpts only when exists and never on "Grid" style posts for the image format (unless it's a portfolio item which would have $post_type=portfolio) // if (strlen($excerpt) && !(isset($portfolio) && get_post_format() == 'image' && $post_type == 'post')) { if (strlen($excerpt) && !(get_post_format() == 'image' && $post_type == 'post')) { ?> <p><?php echo !in_array($excerptLength, array('0', '-1')) ? customExcerpt($excerpt, $excerptLength) : ''; ?> </p> <?php } if (!isset($portfolio)) { if (isset($readMore) && !empty($readMore) && $readMore != -1 && !in_array(get_post_format(), $readMore_Exclude)) { ?> <p class="readmore"><a href="<?php the_permalink(); ?> " class="btn small"><?php echo $readMore; ?> </a></p> <?php } } ?> </div><!-- .entry-summary --> <?php } elseif (!(!is_single() && $post_type == 'portfolio')) { ?> <div class="entry-content"> <?php the_content(__('Continue reading <span class="meta-nav">→</span>', 'framework')); ?> <?php wp_link_pages(array('before' => '<div class="page-links">' . __('Pages:', 'framework'), 'after' => '</div>')); ?> </div><!-- .entry-content --> <?php } // Footer if ($post_type == 'post' && !isset($portfolio)) { ?> <footer class="entry-footer entry-meta"> <?php if (is_single()) { edit_post_link(__('Edit', 'framework'), '<span class="edit-link">', '</span>'); } if (get_post_format() == 'image' && !is_single()) { // Image post format, title in footer theme_post_title(); } // theme_post_meta(); theme_post_tags(); if (is_single() && get_the_author_meta('description') && is_multi_author()) { // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?> <div class="author-info"> <div class="author-avatar"> <?php echo get_avatar(get_the_author_meta('user_email'), apply_filters('theme_author_bio_avatar_size', 68)); ?> </div><!-- .author-avatar --> <div class="author-description"> <h2><?php printf(__('About %s', 'framework'), get_the_author()); ?> </h2> <p><?php the_author_meta('description'); ?> </p> <div class="author-link"> <a href="<?php echo esc_url(get_author_posts_url(get_the_author_meta('ID'))); ?> " rel="author"> <?php printf(__('View all posts by %s <span class="meta-nav">→</span>', 'framework'), get_the_author()); ?> </a> </div><!-- .author-link --> </div><!-- .author-description --> </div><!-- .author-info --> <?php } ?> </footer><!-- .entry-meta --> <?php } else { if ($post_type == 'post' && isset($portfolio)) { // This is the alternate footer for grid style post lists ?> <footer class="entry-footer entry-meta"> <?php // Read more if (isset($readMore) && !empty($readMore) && $readMore != -1 && !in_array(get_post_format(), $readMore_Exclude)) { ?> <p class="readmore"><a href="<?php the_permalink(); ?> " class="btn small"><?php echo $readMore; ?> </a></p> <?php } // Meta details theme_post_meta(); ?> </footer><!-- .entry-meta --> <?php } } // End Footer }