/**
  * /**
  * 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">
 /**
  * Save the primary term for a specific taxonomy
  *
  * @param int     $post_ID  Post ID to save primary term for.
  * @param WP_Term $taxonomy Taxonomy to save primary term for.
  */
 protected function save_primary_term($post_ID, $taxonomy)
 {
     $primary_term = filter_input(INPUT_POST, WPSEO_Meta::$form_prefix . 'primary_' . $taxonomy->name . '_term', FILTER_SANITIZE_NUMBER_INT);
     // We accept an empty string here because we need to save that if no terms are selected.
     if (null !== $primary_term && check_admin_referer('save-primary-term', WPSEO_Meta::$form_prefix . 'primary_' . $taxonomy->name . '_nonce')) {
         $primary_term_object = new WPSEO_Primary_Term($taxonomy->name, $post_ID);
         $primary_term_object->set_primary_term($primary_term);
     }
 }
Exemple #7
0
 /**
  * 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();
 }