/** * /** * Get the id of the primary category * * @return int primary category id */ protected function get_primary_category() { $primary_term = new WPSEO_Primary_Term('category', get_the_ID()); return $primary_term->get_primary_term(); }
/** * Get the id of the primary category * * @param WP_Post $post The post in question. * * @return int primary category id */ protected function get_primary_category($post = null) { $post = get_post($post); if ($post === null) { return false; } $primary_term = new WPSEO_Primary_Term('category', $post->ID); return $primary_term->get_primary_term(); }
/** * Retrieve primary category for use as replacement string. * * @return bool|int|null */ private function retrieve_primary_category() { $primary_category = null; if (!empty($this->args->ID)) { $wpseo_primary_category = new WPSEO_Primary_Term('category', $this->args->ID); $term_id = $wpseo_primary_category->get_primary_term(); $term = get_term($term_id); if (!is_wp_error($term) && !empty($term)) { $primary_category = $term->name; } } return $primary_category; }
/** * Add taxonomy crumbs to the crumbs property for a single post */ private function maybe_add_taxonomy_crumbs_for_post() { if (isset($this->options['post_types-' . $this->post->post_type . '-maintax']) && $this->options['post_types-' . $this->post->post_type . '-maintax'] != '0') { $main_tax = $this->options['post_types-' . $this->post->post_type . '-maintax']; if (isset($this->post->ID)) { $terms = wp_get_object_terms($this->post->ID, $main_tax); if (is_array($terms) && $terms !== array()) { $primary_term = new WPSEO_Primary_Term($main_tax, $this->post->ID); if ($primary_term->get_primary_term()) { $breadcrumb_term = get_term($primary_term->get_primary_term(), $main_tax); } else { $breadcrumb_term = $this->find_deepest_term($terms); } if (is_taxonomy_hierarchical($main_tax) && $breadcrumb_term->parent != 0) { $parent_terms = $this->get_term_parents($breadcrumb_term); foreach ($parent_terms as $parent_term) { $this->add_term_crumb($parent_term); } } $this->add_term_crumb($breadcrumb_term); } } } }
<?php /** * Single Default * */ global $exclude_posts; if (have_posts()) { while (have_posts()) { the_post(); $id = get_the_ID(); $cat = new WPSEO_Primary_Term('category', get_the_ID()); $category = get_term($cat->get_primary_term()); $author_id = get_the_author_meta('ID'); $author_username = get_the_author_meta('display_name'); $artist_id = get_post_meta($id, 'db_featured_artist_id', true); exclude_this_post($id); $permalink = get_permalink(); /* if(is_single()) { ?> <div style="position:fixed; margin:0px auto; width:100%;"> <div class="container"> <div class="row"> <div class="col-sm-8"> <div class="single-header-title"><?php the_title(); ?></div> </div> </div> </div> </div> <?php } */ ?> <div id="content">
/** * /** * Get the id of the primary term * * @param string $taxonomy_name Taxonomy name for the term. * * @return int primary term id */ protected function get_primary_term($taxonomy_name) { $primary_term = new WPSEO_Primary_Term($taxonomy_name, $this->get_current_id()); return $primary_term->get_primary_term(); }
/** * /** * Get the id of the primary term * * @param string $taxonomy_name Taxonomy name for the term. * * @return int primary term id */ protected function get_primary_term($taxonomy_name) { $primary_term = new WPSEO_Primary_Term($taxonomy_name, get_the_ID()); return $primary_term->get_primary_term(); }
/** * Get the primary term ID * * @param string $taxonomy Optional. The taxonomy to get the primary term ID for. Defaults to category. * @param null|int|WP_Post $post Optional. Post to get the primary term ID for. * * @return bool|int */ function yoast_get_primary_term_id($taxonomy = 'category', $post = null) { $post = get_post($post); $primary_term = new WPSEO_Primary_Term($taxonomy, $post->ID); return $primary_term->get_primary_term(); }