public static function get_formated_content() { $post = get_post(); $content = get_the_content(); //Apply "the_content" filter : formats shortcodes etc... : $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $allowed_tags = '<br/><br><p><div><h1><h2><h3><h4><h5><h6><a><span><sup><sub><img><i><em><strong><b><ul><ol><li><blockquote><pre>'; /** * Filter allowed HTML tags for a given post. * * @param string $allowed_tags A string containing the concatenated list of default allowed HTML tags. * @param WP_Post $post The post object. */ $allowed_tags = apply_filters('wpak_post_content_allowed_tags', $allowed_tags, $post); $content = strip_tags($content, $allowed_tags); /** * Filter a single post content. * * To override (replace) this default formatting completely, use * "wpak_posts_list_post_content" and "wpak_page_content" filters. * * @param string $content The post content. * @param WP_Post $post The post object. */ $content = apply_filters('wpak_post_content_format', $content, $post); return $content; }
/** * Get content with formatting in place * @param type $more_link_text * @param type $stripteaser * @param type $more_file * @return type */ function get_the_content_with_formatting($more_link_text = '(more...)', $stripteaser = 0) { $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; }
function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; }
function totc_children($atts) { global $post; global $more; $more = 0; $return = ""; $oldpost = $post; if ($post->ID) { $args = array('post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'date', 'order' => 'DESC'); $children = get_posts($args); if ($children) { foreach ($children as $post) { setup_postdata($post); $more = 0; $content = get_the_content(''); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $return .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3> ' . $content; } } } setup_postdata($oldpost); return $return; }
public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $numberposts = isset($instance['numberposts']) ? $instance['numberposts'] : 1; $termargs = array('post_type' => 'glossary', 'post_status' => 'publish', 'numberposts' => $numberposts, 'orderby' => 'rand'); if ($group = $instance['group']) { $termargs['tax_query'] = array(array('taxonomy' => 'wpglossarygroup', 'field' => 'slug', 'terms' => $group)); } $terms = get_posts($termargs); if ($terms && count($terms)) { echo '<ul class="wpglossary widget-list">'; foreach ($terms as $term) { setup_postdata($term); $title = '<a href="' . apply_filters('wpg_term_link', get_post_permalink($term->ID)) . '">' . get_the_title($term->ID) . '</a>'; $desc = ''; $display = $instance['display']; if ($display && $display != 'title') { $desc = $display == 'full' ? apply_filters('the_content', get_the_content(), $main = false) : wpautop(get_the_excerpt()); $desc = '<br>' . $desc; } echo '<li>' . $title . $desc . '</li>'; } wp_reset_postdata(); echo '</ul>'; } else { echo '<em>' . __('No terms available', 'wp-glossary') . '</em>'; } echo $after_widget; }
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content_rss', $content); if ( $cut && !$encode_html ) $encode_html = 2; if ( 1== $encode_html ) { $content = wp_specialchars($content); $cut = 0; } elseif ( 0 == $encode_html ) { $content = make_url_footnote($content); } elseif ( 2 == $encode_html ) { $content = strip_tags($content); } if ( $cut ) { $blah = explode(' ', $content); if ( count($blah) > $cut ) { $k = $cut; $use_dotdotdot = 1; } else { $k = count($blah); $use_dotdotdot = 0; } for ( $i=0; $i<$k; $i++ ) $excerpt .= $blah[$i].' '; $excerpt .= ($use_dotdotdot) ? '...' : ''; $content = $excerpt; } $content = str_replace(']]>', ']]>', $content); echo $content; }
/** * Customize excerpt length and style. * * @param string The raw post content. * @return string */ function red_wp_trim_excerpt($text) { $raw_excerpt = $text; if ('' == $text) { // retrieve the post content $text = get_the_content(''); // delete all shortcode tags from the content $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); // indicate allowable tags $allowed_tags = '<p>,<a>,<em>,<strong>,<blockquote>,<cite>'; $text = strip_tags($text, $allowed_tags); // change to desired word count $excerpt_word_count = 50; $excerpt_length = apply_filters('excerpt_length', $excerpt_word_count); // create a custom "more" link $excerpt_end = '<span>[...]</span><p><a href="' . get_permalink() . '" class="read-more">Read more →</a></p>'; // modify excerpt ending $excerpt_more = apply_filters('excerpt_more', ' ' . $excerpt_end); // add the elipsis and link to the end if the word count is longer than the excerpt $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }
/** * Allows post excerpts to contain HTML tags * @since mantra 1.8.7 * @return string Excerpt with most HTML tags intact */ function mantra_trim_excerpt($text) { global $mantra_excerptwords; global $mantra_excerptcont; global $mantra_excerptdots; $raw_excerpt = $text; if ('' == $text) { //Retrieve the post content. $text = get_the_content(''); //Delete all shortcode tags from the content. $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); $allowed_tags = '<a>,<img>,<b>,<strong>,<ul>,<li>,<i>,<h1>,<h2>,<h3>,<h4>,<h5>,<h6>,<pre>,<code>,<em>,<u>,<br>,<p>'; $text = strip_tags($text, $allowed_tags); $words = preg_split("/[\n\r\t ]+/", $text, $mantra_excerptwords + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $mantra_excerptwords) { array_pop($words); $text = implode(' ', $words); $text = $text . ' ' . $mantra_excerptdots . ' <a href="' . get_permalink() . '">' . $mantra_excerptcont . ' <span class="meta-nav">→ </span>' . '</a>'; } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }
function the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '', $echo = true) { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0 && $thisshouldnotapply) { echo $content; } else { if (strlen($content) > $max_char && ($espacio = strpos($content, " ", $max_char))) { $content = substr($content, 0, $espacio); if ($echo == true) { echo $content . "..."; } else { return $content; } } else { if ($echo == true) { echo $content . "..."; } else { return $content; } } } }
function get_the_content_limit($max_char, $more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { $content = get_the_content($more_link_text, $stripteaser, $more_file); $content = apply_filters('get_the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = strip_tags($content); if (strlen($_GET['p']) > 0) { echo $content; } else { if (strlen($content) > $max_char && ($espacio = strpos($content, " ", $max_char))) { $content = substr($content, 0, $espacio); $content = $content; echo $content; //echo "<a href='"; //the_permalink(); echo "..."; echo "<br>"; echo "<div class="; echo "'read-more'>"; echo "<a href='"; the_permalink(); echo "'>" . $more_link_text . "</a></div></p>"; } else { echo $content; } } }
public function shortcode($atts, $content = null) { global $post; if ('dt_benefits' == get_post_type()) { return ''; } self::$shortcodes_count++; $this->sanitize_attributes($atts); $output = ''; $dt_query = $this->get_posts_by_terms($this->atts); if ($dt_query->have_posts()) { $this->backup_post_object(); $benefits = ''; while ($dt_query->have_posts()) { $dt_query->the_post(); $benefit_attr = $this->get_benefit_data(); $benefit_content = apply_filters('the_content', get_the_content('')); $benefits .= $this->render_benefit($benefit_attr, $benefit_content); } $this->restore_post_object(); $output .= '<section id="' . $this->get_shortcode_id() . '" ' . $this->get_container_html_class('benefits-grid wf-container') . $this->get_conatiner_data_attributes() . '>'; $output .= $this->get_inline_stylesheet(); $output .= $benefits; $output .= '</section>'; } return $output; }
function efs_get_slider() { /**Options Array...to be added on admin later...*/ $showTitle = true; $showText = true; $beforeTitle = "<strong>"; $afterTitle = "</strong>"; $slider = '<div class="flexslider contain"> <ul class="slides">'; $efs_query = "post_type=slider-image"; query_posts($efs_query); if (have_posts()) { while (have_posts()) { the_post(); $img = get_the_post_thumbnail($post->ID, 'large'); $slider .= '<li>' . $img; if ($showTitle || $showText) { $slider .= '<p class="flex-caption">'; $slider .= $showTitle ? $beforeTitle . get_the_title() . $afterTitle : ''; $slider .= $showText ? '<br/>' . get_the_content() : ''; $slider .= '</p>'; } $slider .= '</li>'; } } wp_reset_query(); $slider .= '</ul> </div>'; return $slider; }
function content($car = 800, $post_id=null){ $disc = get_the_content($post_id); if(strlen($disc) > $car){ $disc = substr($disc, 0, $car).'...'; } echo $disc; }
function get_the_content_our_way($more, $strip_teaser) { if (!in_category(array('tylerdibiasio', 'mishatownsend', 'korwinbriggs', 'twogirls', 'thefinerthings'))) { $content = get_the_content($more, $strip_teaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return "{$content}"; } else { //get the category if (in_category('tylerdibiasio')) { $href = "<a href=\"" . get_option('siteurl') . "/category/tylerdibiasio\">"; } elseif (in_category('mishatownsend')) { $href = "<a href=\"" . get_option('siteurl') . "/category/mishatownsend\">"; } elseif (in_category('korwinbriggs')) { $href = "<a href=\"" . get_option('siteurl') . "/category/korwinbriggs\">"; } elseif (in_category('twogirls')) { $href = "<a href=\"" . get_option('siteurl') . "/category/twogirls\">"; } elseif (in_category('thefinerthings')) { $href = "<a href=\"" . get_option('siteurl') . "/category/thefinerthings\">"; } $content = get_the_content($more, $strip_teaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); $content = preg_replace('/(.*)(<a.*?href.*?\\>)/is', "\\1{$href}", $content); return "{$content}"; } }
protected function init_slides(WP_Query $query) { if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $slide = new stdClass(); $post_id = get_the_ID(); $slide->image_src = wp_get_attachment_image_src($post_id, 'full'); $slide->image_alt = get_post_meta($post_id, '_wp_attachment_image_alt', true); $slide->link = get_post_meta($post_id, 'dt-img-link', true); $slide->video_url = get_post_meta($post_id, 'dt-video-url', true); $slide->share_icons = $this->get_slide_share_buttons(); // hide title if (get_post_meta($post_id, 'dt-img-hide-title', true)) { $slide->title = ''; } else { $slide->title = get_the_title(); } $slide->description = get_the_content(); $slide->id = $post_id; $this->slides[] = $slide; } wp_reset_postdata(); } // have_posts }
function nest_custom_excerpt($length_callback = '', $more_callback = '') { global $post; $content = get_the_content(); $trimmed_content = wp_trim_words($content, $length_callback, '... <a class="more" href="' . get_permalink() . '">' . $more_callback . '</a>'); echo $trimmed_content; }
function service_shortcode($atts) { extract(shortcode_atts(array('category' => '', 'type' => '', 'sitem' => ''), $atts, 'wishlist')); $service_return = ''; $service_return .= '<div class="container"><div class="row">'; $q = new WP_Query(array('post_type' => array('service'), 'post_status' => array('publish'), 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => $sitem, 'service-category' => $category)); $service_return = '<div class="item active">'; while ($q->have_posts()) { $q->the_post(); //$idz = get_the_ID(); $icon = get_post_meta(get_the_ID(), 'serviceIcon', true); if ($icon != '' && $icon != 1) { $ico = 'fa ' . $icon; } else { $ico = 'fa fa-bomb'; } $service_return .= ' <div class="col-md-3 col-sm-6 wow zoomIn text-center" data-wow-duration="700ms" data-wow-delay="300ms"> <div class="service-icon"> <i class="' . $ico . '"></i> </div> <div class="service-text"> <h4>' . get_the_title() . '</h4> <p>' . substr(get_the_content(), 0, 150) . '</p> </div> </div> '; } $service_return .= '</div>'; wp_reset_query(); $service_return .= '</div>'; return $service_return; }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { if ($this->get_cached_widget($args)) { return; } global $job_manager; extract($args); if ('' == get_the_content()) { return; } $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); $icon = isset($instance['icon']) ? $instance['icon'] : null; if ($icon) { $before_title = sprintf($before_title, 'ion-' . $icon); } ob_start(); echo $before_widget; remove_filter('the_content', array($job_manager->post_types, 'job_content')); if ($title) { echo $before_title . $title . $after_title; } do_action('listify_widget_job_listing_content_before'); the_content(); $listing_title = get_the_title(); echo '<table class="table table-no-border"><tr><td colspan="3"><span class="labelHeading">About HobbyGaze</span></td></tr><tr><td colspan="3">HobbyGaze is an online portal to help you discover places where you can do things you truly love. Whether you want to learn new skills, have fun time with friends or get fit, you can find all these places on HobbyGaze. In the fun category, you can find places for paintball, laser tagging, bowling, go- karting, amusement parks and so on. In the fitness category, you can find gyms, yoga studios, fitness studios, dance, zumba, etc. In the learning category, you will find places for learning arts like singing, painting, dancing. HobbyGaze also lists places to learn new languages, sports etc.<br/>So the next time when you are confused about what to do in your free time, just checkout HobbyGaze and spend your time in a meaningful, satisfactory way! This is the HobbyGaze listing of ' . $listing_title . '</td></tr></table>'; do_action('listify_widget_job_listing_content_after'); echo $after_widget; $content = ob_get_clean(); echo apply_filters($this->widget_id, $content); $this->cache_widget($args, $content); }
/** * Return the HTML output for first image found for a post. * * @param int post_id ID for parent post * @param string the_content * @param string before Optional before string * @param string after Optional after string * @return boolean|string HTML output or false if no match */ function esquire_image_grabber( $post_id, $the_content = '', $before = '', $after = '' ) { global $wpdb; $image_src = ''; if ( empty( $the_content ) ) $the_content = get_the_content(); $first_image = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'attachment' AND INSTR(post_mime_type, 'image') ORDER BY menu_order ASC LIMIT 0,1", (int) $post_id ) ); if ( ! empty( $first_image ) ) { // We have an attachment, so just use its data. $image_src = wp_get_attachment_image( $first_image, 'image' ); } else { // Try to get the image for the linked image (not attached) $output = preg_match( WPCOM_THEMES_IMAGE_REGEX, $the_content, $matches ); if ( isset( $matches[0] ) ) $image_src = $matches[0]; } if ( ! empty( $image_src ) ) { // Add wrapper markup, if specified if ( ! empty( $before ) ) $image_src = $before . $image_src; if ( ! empty( $after ) ) $image_src = $image_src . $after; return $image_src; } return false; }
/** A nice shortcode to output a table of cookies you have saved, output in ascending alphabetical order. If there are no cookie records found a single empty row is shown. You can customise the 'not shown' message (see commented code below) N.B. This only shows the information you entered on the "cookie" admin page, it does not necessarily mean you comply with the cookie law. It is up to you, or the website owner, to make sure you have conducted an appropriate cookie audit and are informing website visitors of the actual cookies that are being stored. Usage: [cookie_audit] [cookie_audit style="winter"] [cookie_audit not_shown_message="No records found"] [cookie_audit style="winter" not_shown_message="Not found"] Styles included: simple, classic, modern, rounded, elegant, winter. Default style applied: classic. Additional styles: You can customise the CSS by editing the CSS file itself, included with plugin. */ function cookielawinfo_table_shortcode($atts) { /** RICHARDASHBY EDIT: only add CSS if table is being used */ wp_enqueue_style('cookielawinfo-table-style'); /** END EDIT */ extract(shortcode_atts(array('style' => 'classic', 'not_shown_message' => ''), $atts)); global $post; $args = array('post_type' => 'cookielawinfo', 'posts_per_page' => 50, 'order' => 'ASC', 'orderby' => 'title'); $cookies = new WP_Query($args); $ret = '<table class="cookielawinfo-' . $style . '"><thead><tr>'; $ret .= '<th class="cookielawinfo-column-1">Cookie</th>'; $ret .= '<th class="cookielawinfo-column-2">Type</th>'; $ret .= '<th class="cookielawinfo-column-3">Duration</th>'; $ret .= '<th class="cookielawinfo-column-4">Description</th></tr>'; $ret .= '</thead><tbody>'; if (!$cookies->have_posts()) { $ret .= '<tr class="cookielawinfo-row"><td colspan="2" class="cookielawinfo-column-empty">' . $not_shown_message . '</td></tr>'; } while ($cookies->have_posts()) { $cookies->the_post(); // Get custom fields: $custom = get_post_custom($post->ID); $cookie_type = isset($custom["_cli_cookie_type"][0]) ? $custom["_cli_cookie_type"][0] : ''; $cookie_duration = isset($custom["_cli_cookie_duration"][0]) ? $custom["_cli_cookie_duration"][0] : ''; // Output HTML: $ret .= '<tr class="cookielawinfo-row"><td class="cookielawinfo-column-1">' . get_the_title() . '</td>'; $ret .= '<td class="cookielawinfo-column-2">' . $cookie_type . '</td>'; $ret .= '<td class="cookielawinfo-column-3">' . $cookie_duration . '</td>'; $ret .= '<td class="cookielawinfo-column-4">' . get_the_content() . '</td>'; $ret .= '</tr>'; } $ret .= '</tbody></table>'; return $ret; }
function porto_get_excerpt($limit = 45, $more_link = true) { global $porto_settings; if (!$limit) { $limit = 45; } if (has_excerpt()) { $content = strip_tags(strip_shortcodes(get_the_excerpt())); } else { $content = strip_tags(strip_shortcodes(get_the_content())); } $content = explode(' ', $content, $limit); if (count($content) >= $limit) { array_pop($content); if ($more_link) { $content = implode(" ", $content) . '... '; } else { $content = implode(" ", $content) . ' [...]'; } } else { $content = implode(" ", $content); } if ($porto_settings['blog-excerpt-type'] == 'html') { $content = apply_filters('the_content', $content); $content = do_shortcode($content); } if ($more_link) { $content .= ' <a class="read-more" href="' . esc_url(apply_filters('the_permalink', get_permalink())) . '">' . __('read more', 'porto') . ' <i class="fa fa-angle-right"></i></a>'; } if ($porto_settings['blog-excerpt-type'] != 'html') { $content = '<p class="post-excerpt">' . $content . '</p>'; } return $content; }
function bambule_grab_url() { if (!preg_match('/<a\\s[^>]*?href=[\'"](.+?)[\'"]/i', get_the_content(), $links)) { return false; } return esc_url_raw($links[1]); }
/** * Get post excerpt * * @since 1.0.0 * @param array $args array of arguments. * @param [type] $type - post, term. * @param int $id ID of post. * @return string */ public function get_content($args = array(), $type = 'post', $id = 0) { $object = call_user_func(array($this, 'get_' . $type . '_object'), $id); if ('post' === $type && empty($object->ID) || 'term' === $type && empty($object->term_id)) { return ''; } $default_args = array('visible' => true, 'content_type' => 'post_content', 'length' => -1, 'trimmed_type' => 'word', 'ending' => '…', 'html' => '<p %1$s>%2$s</p>', 'class' => '', 'echo' => false); $args = wp_parse_args($args, $default_args); $html = ''; if (filter_var($args['visible'], FILTER_VALIDATE_BOOLEAN)) { if ('term' === $type) { $text = $object->description; } elseif ('post_content' === $args['content_type'] || 'post_excerpt' === $args['content_type'] && empty($object->{$args}['content_type'])) { $text = get_the_content(); } else { $text = get_the_excerpt(); } $text = $this->cut_text($text, $args['length'], $args['trimmed_type'], $args['ending'], true); if ($text) { $html_class = $args['class'] ? 'class="' . $args['class'] . '"' : ''; $html = sprintf($args['html'], $html_class, $text); } } $html = apply_filters('the_content', $html); return $this->output_method($html, $args['echo']); }
function content($num) { $link = get_permalink(); $ending = get_option('wl_content_ending'); $theContent = get_the_content(); $output = preg_replace('/<img[^>]+./','', $theContent); $limit = $num+1; $content = explode(' ', $output, $limit); array_pop($content); $content = implode(" ",$content).$ending; $imgBeg = strpos($theContent, '<img'); $post = substr($theContent, $imgBeg); $imgEnd = strpos($post, '>'); $postOutput = substr($post, 0, $imgEnd+1); $result = preg_match('/width="([0-9]*)" height="([0-9]*)"/', $postOutput, $matches); if ($result) { $pagestring = $matches[0]; $postOutput = str_replace($pagestring, "", $postOutput); } if(stristr($postOutput,'<img src=')) { echo '<a href="'.$link.'">'.$postOutput."</a>".$content; } else { echo $content; } $readmore = get_option('wl_readmore_link'); if($readmore!="") { $readmore = '<p class="readmore"><a href="'.$link.'">'.$readmore.'</a></p>'; echo $readmore; } }
/** * Smart Excerpt * * Returns an excerpt which is not longer than the given length and always * ends with a complete sentence. If first sentence is longer than length, * it will add the standard ellipsis… Length is the number of characters. * * Usage: <?php smart_excerpt(450); > * * http://www.distractedbysquirrels.com/blog/wordpress-improved-dynamic-excerpt */ function smart_excerpt($length, $postId = false) { if ($postId) { $post = get_post($postId); $text = $post->post_excerpt; } else { global $post; $text = $post->post_excerpt; } if ('' == $text) { if ($postId) { $text = $post->post_content; } else { $text = get_the_content(''); } $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } $text = strip_shortcodes($text); $text = wp_strip_all_tags($text, true); if (empty($length)) { $length = 300; } $text = substr($text, 0, $length); $excerpt = nucleus_reverse_strrchr($text, '.', 1); if ($excerpt) { echo apply_filters('the_excerpt', $excerpt); } else { echo apply_filters('the_excerpt', $text . '…'); } }
function film_shortcode_query($atts, $content) { extract(shortcode_atts(array('posts_per_page' => '1', 'post_type' => 'landing', 'caller_get_posts' => 1), $atts)); global $post; $posts = new WP_Query($atts); $output = ''; if ($posts->have_posts()) { while ($posts->have_posts()) { $posts->the_post(); $out = '<div class="film_box"> <h4>Film Name: <a href="' . get_permalink() . '" title="' . get_the_title() . '">' . get_the_title() . '</a></h4> <p class="Film_desc">' . get_the_content() . '</p>'; // add here more... $out .= '</div>'; /* these arguments will be available from inside $content get_permalink() get_the_content() get_the_category_list(', ') get_the_title() and custom fields get_post_meta($post->ID, 'field_name', true); */ } } else { return; } // no posts found wp_reset_query(); return html_entity_decode($out); }
/** * Return the URL for the first link found in the post content. * * @since Twenty Eleven 1.0 * @return string|bool URL or false when no link is present. */ function twentyeleven_url_grabber() { if (!preg_match('/<a\\s[^>]*?href=[\'"](.+?)[\'"]/is', get_the_content(), $matches)) { return false; } return esc_url_raw($matches[1]); }
public static function friend_list_func($atts, $content = "") { $atts = shortcode_atts(array('per_page' => '100'), $atts, 'friend_list'); $return = ""; query_posts(array('post_type' => 'friend', 'showposts' => $atts['per_page'], 'meta_query' => array('relation' => 'AND', array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_male.gif', 'compare' => 'NOT LIKE'), array('key' => 'avatar150', 'value' => 'https://static0.fitbit.com/images/profile/defaultProfile_100_female.gif', 'compare' => 'NOT LIKE')))); if (have_posts()) { while (have_posts()) { the_post(); $displayName = get_post_meta(get_the_id(), 'displayName', true); $avatar = get_post_meta(get_the_id(), 'avatar150', true); $return .= sprintf('<div class="col-lg-3 col-sm-3 focus-box"> <div class="service-icon"> <i style="background:url(%s) no-repeat center;width:100%%; height:100%%;" class="pixeden"></i> </div> <h3 class="red-border-bottom">%s</h3> <a class="btn btn-primary btn-block green-btn btn-sm" href="https://www.fitbit.com/user/%s"><i class="fa fa-plus"></i> Add Friend</a> <br/> </div>', $avatar, $displayName, get_the_title(), get_the_content()); } $return = '<div class="hwd-wrapper"><div class="row">' . $return . '</div></div>'; } else { $return = 'No Friends Found'; } wp_reset_query(); return $return; }
function shortcode_faqs($atts, $content = null) { extract($atts = shortcode_atts(array('counts' => '12', 'cats' => '', 'posts' => '', 'order' => 'DESC', 'orderby' => 'date', 'filter' => 'yes', 'post_type' => 'faq', 'taxonomy' => 'faq_cat'), $atts)); // Get Query $query = new Twoot_Query(array('counts' => $counts, 'cats' => $cats, 'posts' => $posts, 'order' => $order, 'orderby' => $orderby, 'post_type' => $post_type, 'taxonomy' => $taxonomy)); $grid = new Twoot_Template_Grid(); $do_query = new WP_Query($query->do_template_query()); $faqs_class = $filter == 'yes' ? 'column nine' : 'twelve'; $html = '<div class="the-faq-list shortcode-toggle outer clearfix">' . "\n"; if ($filter == 'yes') { $html .= '<div class="column three">'; $html .= $grid->filter_terms_menu($do_query->posts, $atts); $html .= '</div>'; } $html .= '<div id="faqs" class="' . $faqs_class . '">'; while ($do_query->have_posts()) { $do_query->the_post(); //Get terms class $terms_class = $grid->filter_terms_class(get_the_ID(), $atts); $html .= '<div class="tog-item faq-item inner ' . $terms_class . '">'; $html .= '<a href="#" class="tog"><i class="icon twoot-icon"></i>' . get_the_title() . '</a>'; $html .= '<div class="tog-content clearfix">' . do_shortcode(get_the_content()) . '</div>'; $html .= '</div>'; } wp_reset_query(); $html .= '</div>'; $html .= '</div>'; return $html; }
function custom_wp_trim_excerpt($text) { $raw_excerpt = $text; if ('' == $text) { //Retrieve the post content. $text = get_the_content(''); $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); // the code below sets the excerpt length to 55 words. You can adjust this number for your own blog. $excerpt_length = apply_filters('excerpt_length', 55); // the code below sets what appears at the end of the excerpt, in this case ... $excerpt_more = apply_filters('excerpt_more', ' ' . '...'); $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); if (count($words) > $excerpt_length) { array_pop($words); $text = implode(' ', $words); $text = force_balance_tags($text); $text = $text . $excerpt_more; } else { $text = implode(' ', $words); } } return apply_filters('wp_trim_excerpt', $text, $raw_excerpt); }