function base_getBreadcrumbs() { if (is_404()) { return false; } // Hack to fix breadcrumbs when you're viewing the news home if (is_home()) { $post = new \Timber\Post(get_option('page_for_posts')); } else { global $post; } $breadcrumbs = []; if ($post->post_parent) { $parent_id = $post->post_parent; while ($parent_id) { $page = get_page($parent_id); $breadcrumbs[] = new \Timber\Post($page->ID); $parent_id = $page->post_parent; } $breadcrumbs = array_reverse($breadcrumbs); } // Add 'Blog Home' to breadcrumbs if you're on a news post or archive if ((is_single() || is_archive()) && !is_search()) { $breadcrumbs[] = new \Timber\Post(get_option('page_for_posts')); } return $breadcrumbs; }
function tie_register() { ## Register Main style.css file wp_register_style('tie-style', get_stylesheet_uri(), array(), '', 'all'); wp_enqueue_style('tie-style'); ## Register All Scripts wp_register_script('tie-scripts', get_template_directory_uri() . '/js/tie-scripts.js', array('jquery'), false, true); wp_register_script('tie-tabs', get_template_directory_uri() . '/js/tabs.min.js', array('jquery'), false, true); wp_register_script('tie-cycle', get_template_directory_uri() . '/js/jquery.cycle.all.js', array('jquery'), false, true); wp_register_script('tie-validation', get_template_directory_uri() . '/js/validation.js', array('jquery'), false, true); wp_register_script('tie-flexslider', get_template_directory_uri() . '/js/jquery.flexslider-min.js', array('jquery'), false, true); ## Get Global Scripts wp_enqueue_script('tie-scripts'); ## Register WooCommerce css file wp_register_style('tie-woocommerce', get_template_directory_uri() . '/css/woocommerce.css', array(), '', 'all'); if (class_exists('Woocommerce')) { wp_enqueue_style('tie-woocommerce'); } ## Get Validation Script if (tie_get_option('comment_validation') && (is_page() || is_single()) && comments_open()) { wp_enqueue_script('tie-validation'); } ## For facebook & Google + share if (is_singular() && tie_get_option('post_og_cards') && (!function_exists('bp_current_component') || function_exists('bp_current_component') && !bp_current_component())) { tie_og_data(); } }
/** * Register the stylesheets for the public-facing side of the site. * * @since 1.0.0 */ public function enqueue_scripts() { global $post, $product; if (is_object($post) && class_exists('WooCommerce')) { $is_product_type_variable = 'false'; if (function_exists('wc_get_product')) { $product = wc_get_product($post); if ($product) { if ($product->is_type('variable') && is_single()) { $is_product_type_variable = 'true'; } } } $attach_id = isset($_SESSION['attach_id']) && !empty($_SESSION['attach_id']) ? $_SESSION['attach_id'] : ''; if (!empty($attach_id)) { $total_word = get_post_meta($attach_id, 'total_word', true); } else { $total_word = ''; } if (!empty($attach_id)) { $total_character = get_post_meta($attach_id, 'total_character', true); } else { $total_character = ''; } wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/woocommerce-price-per-word-public.js', array('jquery'), $this->version, false); if (wp_script_is($this->plugin_name)) { wp_localize_script($this->plugin_name, 'woocommerce_price_per_word_params', apply_filters('woocommerce_price_per_word_params', array('ajax_url' => admin_url('admin-ajax.php'), 'woocommerce_price_per_word_params_nonce' => wp_create_nonce("woocommerce_price_per_word_params_nonce"), 'total_word' => $total_word, 'total_character' => $total_character, 'is_product_type_variable' => $is_product_type_variable, 'woocommerce_currency_symbol_js' => get_woocommerce_currency_symbol(), 'woocommerce_price_num_decimals' => wc_get_price_decimals(), 'aewcppw_word_character' => $this->wppw_get_product_type(), 'aewcppw_allow_users_to_enter_qty' => $this->aewcppw_allow_users_to_enter_qty()))); } wp_enqueue_script($this->plugin_name . '-bn', plugin_dir_url(__FILE__) . 'js/woocommerce-price-per-word-bn.js', array('jquery'), $this->version, false); } }
/** * s2Member's Security Gate (protects WordPress content). * * @package s2Member\Security * @since 3.5 * * @attaches-to ``add_action("wp");`` * * @return null May redirect a browser *(exiting script execution)*, when/if content is NOT available to the current User/Member. */ public static function security_gate() { do_action("ws_plugin__s2member_before_security_gate", get_defined_vars()); if (is_category()) { // Categories & other inclusives. c_ws_plugin__s2member_catgs::check_catg_level_access(); } else { if (is_tag()) { // Post/Page Tags & other inclusives. c_ws_plugin__s2member_ptags::check_ptag_level_access(); } else { if (is_single()) { // All Posts & other inclusives. c_ws_plugin__s2member_posts::check_post_level_access(); } else { if (is_page()) { // All Pages & other inclusives. c_ws_plugin__s2member_pages::check_page_level_access(); } else { // Else, we simply look at URIs & other inclusives. c_ws_plugin__s2member_ruris::check_ruri_level_access(); } } } } do_action("ws_plugin__s2member_after_security_gate", get_defined_vars()); return; }
/** * returns the language based on the queried content * * @since 1.2 * * @return object|bool detected language, false if none was found */ protected function get_language_from_content() { // no language set for 404 if (is_404() || is_attachment() && !$this->options['media_support']) { return $this->get_preferred_language(); } if ($var = get_query_var('lang')) { $lang = explode(',', $var); $lang = $this->model->get_language(reset($lang)); // choose the first queried language } elseif ((is_single() || is_page() || is_attachment() && $this->options['media_support']) && (($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) || ($var = get_query_var('attachment_id')))) { $lang = $this->model->post->get_language($var); } else { foreach ($this->model->get_translated_taxonomies() as $taxonomy) { if ($var = get_query_var(get_taxonomy($taxonomy)->query_var)) { $lang = $this->model->term->get_language($var, $taxonomy); } } } /** * Filter the language before it is set from the content * * @since 0.9 * * @param bool|object $lang language object or false if none was found */ return apply_filters('pll_get_current_language', isset($lang) ? $lang : false); }
public function already_applied_title($title, $post_id) { if ('job_listing' === get_post_type($post_id) && !is_single() && is_user_logged_in() && user_has_applied_for_job(get_current_user_id(), $post_id)) { $title .= ' <span class="job-manager-applications-applied-notice">' . __('Applied', 'wp-job-manager-applications') . '</span>'; } return $title; }
/** * Scripts and stylesheets * * Enqueue stylesheets in the following order: * 1. /theme/assets/css/main.css * * Enqueue scripts in the following order: * 1. jquery-1.11.1.min.js via Google CDN * 2. /theme/assets/js/vendor/modernizr.min.js * 3. /theme/assets/js/scripts.js (in footer) * * Google Analytics is loaded after enqueued scripts if: * - An ID has been defined in config.php * - You're not logged in as an administrator */ function roots_scripts() { /** * The build task in Grunt renames production assets with a hash * Read the asset names from assets-manifest.json */ if (WP_ENV === 'development') { $assets = array('css' => '/assets/css/main.css', 'js' => '/assets/js/scripts.js', 'modernizr' => '/assets/vendor/modernizr/modernizr.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.js'); } else { $get_assets = file_get_contents(get_template_directory() . '/assets/manifest.json'); $assets = json_decode($get_assets, true); $assets = array('css' => '/assets/css/main.min.css' . '?' . $assets['assets/css/main.min.css']['hash'], 'js' => '/assets/js/scripts.min.js' . '?' . $assets['assets/js/scripts.min.js']['hash'], 'modernizr' => '/assets/js/vendor/modernizr.min.js', 'jquery' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'); } wp_enqueue_style('roots_css', get_template_directory_uri() . $assets['css'], false, null); /** * jQuery is loaded using the same method from HTML5 Boilerplate: * Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline * It's kept in the header instead of footer to avoid conflicts with plugins. */ if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); wp_register_script('jquery', $assets['jquery'], array(), null, false); add_filter('script_loader_src', 'roots_jquery_local_fallback', 10, 2); } if (is_single() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } wp_enqueue_script('modernizr', get_template_directory_uri() . $assets['modernizr'], array(), null, false); wp_enqueue_script('jquery'); wp_enqueue_script('roots_js', get_template_directory_uri() . $assets['js'], array(), null, true); }
/** * Enqueue scripts and stylesheets * * Enqueue stylesheets in the following order: * 1. /theme/assets/css/main.min.css * * Enqueue scripts in the following order: * 1. jquery-1.11.0.min.js via Google CDN * 2. /theme/assets/js/vendor/modernizr-2.7.2.min.js * 3. /theme/assets/js/main.min.js (in footer) */ function alfath_scripts() { wp_enqueue_style('alfath_main', get_template_directory_uri() . '/assets/css/main.min.css', false, '1.0.0'); wp_enqueue_style('alfath_fa-icon', get_template_directory_uri() . '/assets/css/font-awesome.min.css', false, '4.0.3'); wp_enqueue_style('alfath-icon', get_template_directory_uri() . '/assets/css/alfath-icon.min.css', false, '1.0.0'); if (file_exists(get_template_directory() . '/assets/css/custom.css')) { wp_enqueue_style('alfath_custom', get_template_directory_uri() . '/assets/css/custom.css', array('alfath_main'), filemtime(get_template_directory() . '/assets/css/custom.css'), 'all'); } // jQuery is loaded using the same method from HTML5 Boilerplate: // Grab Google CDN's latest jQuery with a protocol relative URL; fallback to local if offline // It's kept in the header instead of footer to avoid conflicts with plugins. if (!is_admin() && current_theme_supports('jquery-cdn')) { wp_deregister_script('jquery'); wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js', false, null, false); add_filter('script_loader_src', 'alfath_jquery_local_fallback', 10, 2); } if (is_single() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.7.2.min.js', false, null, false); wp_register_script('jquery-migrate', get_template_directory_uri() . '/assets/js/vendor/jquery-migrate-1.2.1.min.js', array('jquery'), null, false); wp_register_script('alfath_scripts', get_template_directory_uri() . '/assets/js/scripts.min.js', false, '1.0.0', true); wp_enqueue_script('modernizr'); wp_enqueue_script('jquery'); wp_enqueue_script('jquery-migrate'); wp_enqueue_script('alfath_scripts'); }
function hatom_data_in_content_single($content) { if (is_single()) { $content .= get_hatom_data_single(); } return $content; }
/** * Generate the add/remove a topic to/from bookmark list link. * * @since 0.0.1 */ function vp_bookmark() { if (!is_user_logged_in() || !is_single()) { return; } $topic_id = get_the_ID(); $user_id = wp_get_current_user()->ID; $bookmarked_num = 0; // Which users already bookmarked this topic $bookmarked = (array) get_post_meta($topic_id, 'v2press_who_bookmarked_me', true); if ('' != $bookmarked[0]) { $bookmarked_num = count($bookmarked); } if (in_array($user_id, $bookmarked)) { $action = 'remove'; $text = __('Remove from Bookmark', 'v2press'); } else { $action = 'add'; $text = __('Add to Bookmark', 'v2press'); } $output = '<div class="favorite-topic">'; if (0 < $bookmarked_num) { $output .= sprintf(_n('%d user bookmarked', '%d users bookmarked', $bookmarked_num, 'v2press'), $bookmarked_num); } $output .= '<a class="fav ' . $action . '" href="?bookmark=' . $action . '&topic=' . $topic_id . '" title="' . esc_attr($text) . '">' . $text . '</a>'; $output .= '</div>'; echo $output; }
/** * Remove all scripts and styles from the estimate view and then add those specific to si. * @return */ public static function remove_scripts_and_styles() { if (SI_Invoice::is_invoice_query() && is_single()) { if (apply_filters('si_remove_scripts_styles_on_doc_pages', '__return_true')) { global $wp_scripts, $wp_styles; $allowed_scripts = apply_filters('si_allowed_doc_scripts', array('sprout_doc_scripts', 'qtip', 'dropdown')); $allowed_admin_scripts = apply_filters('si_allowed_admin_doc_scripts', array_merge(array('admin-bar'), $allowed_scripts)); if (current_user_can('edit_sprout_invoices')) { $wp_scripts->queue = $allowed_admin_scripts; } else { $wp_scripts->queue = $allowed_scripts; } $allowed_styles = apply_filters('si_allowed_doc_styles', array('sprout_doc_style', 'qtip', 'dropdown')); $allowed_admin_styles = apply_filters('si_allowed_admin_doc_styles', array_merge(array('admin-bar'), $allowed_styles)); if (current_user_can('edit_sprout_invoices')) { $wp_styles->queue = $allowed_admin_styles; } else { $wp_styles->queue = $allowed_styles; } do_action('si_doc_enqueue_filtered'); } else { // scripts wp_enqueue_script('sprout_doc_scripts'); wp_enqueue_script('dropdown'); wp_enqueue_script('qtip'); // Styles wp_enqueue_style('sprout_doc_style'); wp_enqueue_style('dropdown'); wp_enqueue_style('qtip'); } } }
function insert_fb_in_head() { global $post; if (!is_single()) { echo '<meta property="fb:app_id" content="964610463630306">'; echo '<meta property="og:title" content="SMS Brandname"/>'; echo '<meta property="og:type" content="website">'; echo '<meta property="og:url" content="' . home_url() . '"/>'; echo '<meta property="og:site_name" content="SMS Brandname"/>'; echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">'; echo ""; return; } // $current_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; echo '<meta property="fb:app_id" content="964610463630306">'; echo '<meta property="og:title" content="' . get_the_title() . '"/>'; echo '<meta property="og:type" content="website">'; echo '<meta property="og:url" content="' . $current_url . '"/>'; echo '<meta property="og:site_name" content="SMS Brandname"/>'; echo '<meta property="og:description" content="Cam kết giá dịch vụ, Tính năng hữu ích, Khác biệt và tươi mới, Tốc độ và niềm tin, Hổ trợ tuyệt vời">'; echo ""; if (is_single()) { $image = get_field('image'); echo '<meta property="og:image" content="' . $image['sizes']['large'] . '"/>'; } else { $default_image = "http://sms.viet-digital.com/wp-content/uploads/2016/03/logo-top.png"; echo '<meta property="og:image" content="' . $default_image . '"/>'; } echo ""; }
function enlightenment_glyphicons_author_posts_link_args($args) { if (!is_single() || doing_action('enlightenment_entry_header')) { $args['format'] = '<span class="glyphicon glyphicon-user"></span> ' . $args['format']; } return $args; }
/** * Gets the page type from WordPress. * * @return string A string representation of the current page type, * corresponding to the values used by publisherplugin.google.com. */ public static function getWordPressPageType() { // is_front_page() returns true if (1) a static front page is set and this // is that page, or (2) the front page is the blog home page and this // is the blog home page. if (is_front_page()) { return 'front'; } if (is_home()) { return 'home'; } if (is_single()) { return 'singlePost'; } if (is_page()) { return 'page'; } if (is_category()) { return 'category'; } if (is_archive()) { return 'archive'; } if (is_search()) { return 'search'; } if (is_404()) { return 'errorPage'; } return ''; }
/** * @since 2.6.1 * Public $item_info * Oget the post location information from database */ public function item_info() { global $members_template; if (is_single() && empty($this->args['show_in_single_post'])) { $this->args['no_location_message'] = false; } if (empty($this->args['item_id']) && empty($members_template->member->ID) && !bp_is_user() && (!is_single() || empty($this->args['show_in_single_post']))) { return false; } if (!empty($this->args['item_id'])) { $this->args['item_id'] = $this->args['item_id']; } elseif (bp_is_user()) { global $bp; $this->args['item_id'] = $bp->displayed_user->id; } elseif (is_single()) { global $post; $this->args['item_id'] = $post->post_author; } elseif (!empty($members_template->member->ID)) { $this->args['item_id'] = $members_template->member->ID; } else { return false; } $item_info = gmw_get_member_info_from_db($this->args['item_id']); return $item_info; }
public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); $description = apply_filters('widget_description', $instance['description']); $link = apply_filters('widget_link', $instance['link']); $button = apply_filters('widget_button', $instance['button']); $imgURL = get_bloginfo('template_url'); // before and after widget arguments are defined by themes echo $args['before_widget']; if (is_single()) { echo '<img src="' . $imgURL . '/img/campaign-splash-sm.png" class="img-responsive campaign-img hidden-xs">'; // smaller img echo '<img src="' . $imgURL . '/img/campaign-splash.jpg" class="img-responsive campaign-img visible-xs">'; // larger img echo "<div class='campaign-content'>"; echo $args['before_title'] . $title . $args['after_title']; echo "<p class='large'>" . $args['before_description'] . $description . $args['after_description'] . "</p>"; echo "</div>"; // echo "<a class='btn btn-primary btn-lg campaign-button' href='http://tilt.climatefeedback.org' target='_blank'>$title</a>"; echo "<a class='btn btn-primary btn-lg campaign-button' href='{$link}' target='_blank'>{$button}</a>"; // This is where you run the code and display the output echo __($args['before_description'], 'wpb_widget_description'); echo $args['after_widget']; } }
/** Add Shop Header */ function spyropress_wc_shop_header() { if (is_single()) { return; } wc_get_template_part('global/shop', 'header'); }
function nav_menu_add_classes2($items, $args) { //print_r($items); global $post; $i = 0; $j = false; $a = false; foreach ($items as $item) { $i++; if (is_single() && get_post_type() == 'interesting-fact') { //get parent page ID by checking which page uses interesting fatcs page template $pages = get_pages(array('meta_key' => '_wp_page_template', 'meta_value' => 'page-templates/interesting_facts.php', 'lang' => pll_current_language('slug'))); $parent_page_id = $pages[0]->ID; if ($item->object_id == $parent_page_id) { // $item->classes[] = 'current_page_parent'; $item->classes[] = 'current_menu_item'; $j = $i - 1; $a = $item->ID; } } } if ($j) { // $items[$j]->classes[] = 'current_page_parent'; $items[1]->classes[] = 'current_page_ancestor'; } if ($a) { echo $a; } return $items; }
public function already_applied_title($title, $post_id = '') { if ($post_id && 'job_listing' === get_post_type($post_id) && !is_single() && empty($_GET['download-csv']) && user_has_applied_for_job(get_current_user_id(), $post_id)) { $title .= ' <span class="job-manager-applications-applied-notice">' . __('Applied', 'wp-job-manager-applications') . '</span>'; } return $title; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); $sticky = get_option('sticky_posts'); $number = empty($instance['number']) ? 1 : (int) $instance['number']; $cat = empty($instance['category']) ? 0 : (int) $instance['category']; if (is_single()) { array_push($sticky, get_the_ID()); } echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } else { echo '<br />'; } $featuredPosts = new WP_Query(array('posts_per_page' => $number, 'cat' => $cat, 'post__not_in' => $sticky, 'no_found_rows' => true)); while ($featuredPosts->have_posts()) { $featuredPosts->the_post(); global $mb_content_area, $more; $mb_content_area = 'sidebar'; get_template_part('content', get_post_format()); } wp_reset_postdata(); echo $after_widget; }
function featureText() { if (is_front_page()) { the_field('feature_text'); } elseif (is_home() || is_single()) { _e('Rock Theme Official Blog'); } elseif (is_archive()) { _e('Rock Theme Official Blog'); _e('<br>'); single_term_title('Browsing: '); if (is_month()) { $monthNum = get_query_var('monthnum'); $month = date('F', mktime(0, 0, 0, $monthNum)); $year = get_query_var('year'); echo 'Posts from ' . $month . ' ' . $year; } } elseif (is_page_template('page-news.php') || is_page_template('page-about.php') || is_page_template('page-contact.php')) { bloginfo('name'); _e('<br>'); the_title(); } elseif (is_404()) { _e('Whoops, were a little lost.'); } elseif (is_search()) { _e('Rock Theme Official Blog'); _e('<br>'); printf('Search results for: %s', get_search_query()); } }
function MyBreadcrumb() { if (!is_home()) { echo '<li><a href="'; echo get_option('home'); echo '/">'; echo 'Home'; echo '</a><span class="divider">/</span></li>'; if (is_category() || is_single()) { echo '<li>'; the_category(', ', '&title_li='); echo '<span class="divider">/</span></li>'; echo '</li>'; if (is_single()) { echo '<li class="active">'; // the_title(); echo '</li>'; } } elseif (is_page()) { echo '<li class="active">'; the_title(); echo '</li>'; } } }
function tography_lite_enqueue_stylesheets() { //Bootstrap ======================================================= wp_register_style('bootstrap', TOGRAPHY_LITE_CSS . '/bootstrap.css', array(), '3.1', 'all'); wp_enqueue_style('bootstrap'); //================================================================= if (is_page_template('page-portfolio-thirds.php') || is_archive()) { //Isotope ================================================ wp_register_style('isotope', TOGRAPHY_LITE_CSS . '/isotope.css', array(), '1.0', 'all'); wp_enqueue_style('isotope'); //================================================================= //Photoswipe ====================================================== wp_register_style('photoswipe', TOGRAPHY_LITE_CSS . '/photoswipe.css', array(), '2.0.0', 'all'); wp_enqueue_style('photoswipe'); //================================================================= //Photoswipe Skin ====================================================== wp_register_style('photoswipe-skin', TOGRAPHY_LITE_CSS . '/default-skin/default-skin.css', array(), '2.0.0', 'all'); wp_enqueue_style('photoswipe-skin'); //================================================================= } if (is_single() || is_archive()) { //Photoswipe ====================================================== wp_register_style('photoswipe', TOGRAPHY_LITE_CSS . '/photoswipe.css', array(), '2.0.0', 'all'); wp_enqueue_style('photoswipe'); //================================================================= //Photoswipe Skin ====================================================== wp_register_style('photoswipe-skin', TOGRAPHY_LITE_CSS . '/default-skin/default-skin.css', array(), '2.0.0', 'all'); wp_enqueue_style('photoswipe-skin'); //================================================================= } //Main Stylesheet ================================================= wp_register_style('main-stylesheet', get_bloginfo('stylesheet_url'), array('bootstrap'), '1.0', 'all'); wp_enqueue_style('main-stylesheet'); //================================================================= }
function blanket_meta_tags() { ?> <meta charset="<?php bloginfo('charset'); ?> "> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"><?php if (is_single()) { global $post; ?> <meta name="author" content="<?php echo get_the_author_meta('display_name', $post->post_author); ?> "><?php } else { ?> <meta name="author" content="<?php echo BLANKET_GET_AUTHOR; ?> "><?php } ?> <link rel="pingback" href="<?php bloginfo('pingback_url'); ?> "><?php }
function widget($args, $instance) { global $post; // Preserve global $post $preserve = $post; extract($args); // only useful on post pages if (!is_single()) { return; } $title = apply_filters('widget_title', empty($instance['title']) ? __('Read Next', 'largo') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $related = new Largo_Related($instance['qty']); //get the related posts $rel_posts = new WP_Query(array('post__in' => $related->ids(), 'nopaging' => 1, 'posts_per_page' => $instance['qty'], 'ignore_sticky_posts' => 1)); if ($rel_posts->have_posts()) { echo '<ul class="related">'; while ($rel_posts->have_posts()) { $rel_posts->the_post(); echo '<li>'; echo '<a href="' . get_permalink() . '"/>' . get_the_post_thumbnail(get_the_ID(), 'thumbnail', array('class' => 'alignleft')) . '</a>'; ?> <h4><a href="<?php the_permalink(); ?> " title="Read: <?php esc_attr(the_title('', '', FALSE)); ?> "><?php the_title(); ?> </a></h4> <h5 class="byline"> <span class="by-author"><?php largo_byline(true, true); ?> </span> <time class="entry-date updated dtstamp pubdate" datetime="<?php echo esc_attr(get_the_date('c')); ?> "><?php largo_time(); ?> </time> </h5> <?php // post excerpt/summary largo_excerpt(get_the_ID(), 2, false, '', true); echo '</li>'; } echo "</ul>"; } echo $after_widget; // Restore global $post wp_reset_postdata(); $post = $preserve; }
public function testThemeTemplateIsCorrectForPost() { $post = $this->factory->post->create(); $this->go_to_with_template(get_permalink($post)); $this->assertTrue(is_single()); $this->assertSame('single.php', self::get_theme_data('template_file')); }
/** * Constructor. * * @param string $name The post identifier. */ public function __construct($name) { $this->name = $name; if (is_single()) { add_action('wp_print_scripts', array(&$this, 'feed_link'), 4); } }
function ninja_forms_get_form_ids_by_post_id($post_id) { global $wpdb; $form_ids = array(); if (is_page($post_id)) { $form_results = ninja_forms_get_all_forms(); if (is_array($form_results) and !empty($form_results)) { foreach ($form_results as $form) { $form_data = $form['data']; if (isset($form_data['append_page']) and !empty($form_data['append_page'])) { if ($form_data['append_page'] == $post_id) { $form_ids[] = $form['id']; } } } } $form_id = get_post_meta($post_id, 'ninja_forms_form', true); if (!empty($form_id)) { $form_ids[] = $form_id; } } else { if (is_single($post_id)) { $form_id = get_post_meta($post_id, 'ninja_forms_form', true); if (!empty($form_id)) { $form_ids[] = $form_id; } } } return $form_ids; }
/** * Prints HTML with meta information for the categories, tags and comments. */ function xmaps_entry_footer() { // Hide category and tag text for pages. if ('post' === get_post_type()) { /* translators: used between list items, there is a space after the comma */ $categories_list = get_the_category_list(esc_html__(', ', 'xmaps')); if ($categories_list && xmaps_categorized_blog()) { printf('<span class="cat-links">' . esc_html__('Posted in %1$s', 'xmaps') . '</span>', $categories_list); // WPCS: XSS OK. } /* translators: used between list items, there is a space after the comma */ $tags_list = get_the_tag_list('', esc_html__(', ', 'xmaps')); if ($tags_list) { printf('<span class="tags-links">' . esc_html__('Tagged %1$s', 'xmaps') . '</span>', $tags_list); // WPCS: XSS OK. } } if (!is_single() && !post_password_required() && (comments_open() || get_comments_number())) { echo '<span class="comments-link">'; /* translators: %s: post title */ comments_popup_link(sprintf(wp_kses(__('Leave a Comment<span class="screen-reader-text"> on %s</span>', 'xmaps'), array('span' => array('class' => array()))), get_the_title())); echo '</span>'; } edit_post_link(sprintf(esc_html__('Edit %s', 'xmaps'), the_title('<span class="screen-reader-text">"', '"</span>', false)), '<span class="edit-link">', '</span>'); }
/** * Add breadcrumbs functionality to your WordPress theme * * Once you have included the function in your functions.php file * you can then place the following anywhere in your theme templates * if(function_exists('bootstrap_breadcrumbs')) bootstrap_breadcrumbs(); * * credit to: c.bavota - http://bavotasan.com (thanks for the code start) */ function bootstrap_breadcrumbs() { echo '<ol class="breadcrumb">'; echo '<li><a href="' . home_url('/') . '">Home</a></li>'; // are we at "blog home"? if (is_home()) { echo '<li><a href="#">Blogs</a></li>'; } // where else do we want breadcrumbs if (!is_page_template('pt-home.php') && !is_home()) { // check if we're in a commerce plugin if (function_exists('is_woocommerce') && is_woocommerce()) { echo '<li><a href="/publications/order/">Shop</a></li>'; $product_cats = wp_get_post_terms(get_the_ID(), 'product_cat'); echo '<li><a href="/publications/order/' . str_replace(" ", "-", $product_cats[0]->name) . '">' . $product_cats[0]->name . '</a></li>'; } // breadcrumb wordpress structures if (is_category() || is_single() || is_single('aof')) { if (get_the_category()) { $category = get_the_category(); echo '<li><a href="/blog/category/' . str_replace(" ", "-", $category[0]->cat_name) . '">' . $category[0]->cat_name . '</a></li>'; } if (is_single()) { echo '<li class="active">'; the_title(); echo '</li>'; } } elseif (is_page()) { echo '<li class="active">'; the_title(); echo '</li>'; } } echo '</ol>'; }