当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_add_post_tags函数代码示例

本文整理汇总了PHP中wp_add_post_tags函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_add_post_tags函数的具体用法?PHP wp_add_post_tags怎么用?PHP wp_add_post_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wp_add_post_tags函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wp_aatags_run

function wp_aatags_run($post_ID)
{
    $tags = get_option('wp_aatags_opts');
    $number = get_option('wp_aatags_aadnumber');
    global $wpdb;
    if (get_post($post_ID)->post_type == 'post' && !wp_is_post_revision($post_ID) && !get_the_tags($post_ID)) {
        $post_title = get_post($post_ID)->post_title;
        $post_content = get_post($post_ID)->post_content;
        switch ($tags) {
            case 3:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 333, ''));
                break;
            case 2:
                $requix = strtolower($post_title . ' ' . wp_trim_words($post_content, 999, ''));
                break;
            default:
                $requix = strtolower($post_title);
                break;
        }
        $body = wp_aatags_keycontents(wp_aatags_html2text($requix), $number);
        if ($body != 'rEr') {
            $keywords = wp_aatags_kwsiconv($body);
            wp_add_post_tags($post_ID, $keywords);
        } else {
            wp_aatags_alts($post_ID, $post_title, $post_content);
        }
    }
}
开发者ID:yszar,项目名称:linuxwp,代码行数:28,代码来源:wp-autotags.php

示例2: save_post_add_tags

 function save_post_add_tags($post_id, $post, $update)
 {
     if ($update) {
         return;
     }
     wp_add_post_tags($post_id, get_option('dgs_default_post_tags', ''));
 }
开发者ID:Daronspence,项目名称:default-post-tags,代码行数:7,代码来源:default-post-tags.php

示例3: check_post_keyword

 function check_post_keyword($precheck = true)
 {
     global $wpdb;
     echo '<div class="narrow">';
     echo '<p><h3>' . __('Reading Bunny&#8217;s Technorati Tags&#8230;') . '</h3></p>';
     // import Bunny's Keywords tags
     $metakeys = $wpdb->get_results("SELECT post_id, meta_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE {$wpdb->postmeta}.meta_key = 'tags'");
     if (!is_array($metakeys)) {
         echo '<p>' . __('No Tags Found!') . '</p>';
         return false;
     } else {
         $count = count($metakeys);
         echo '<p>' . sprintf(__ngettext('Done! <strong>%s</strong> post with tags were read.', 'Done! <strong>%s</strong> posts with tags were read.', $count), $count) . '<br /></p>';
         echo '<ul>';
         foreach ($metakeys as $post_meta) {
             if ($post_meta->meta_value != '') {
                 $post_keys = explode(' ', $post_meta->meta_value);
                 foreach ($post_keys as $keyword) {
                     $keyword = addslashes(trim(str_replace('+', ' ', $keyword)));
                     if ('' != $keyword) {
                         echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
                         if (!$precheck) {
                             wp_add_post_tags($post_meta->post_id, $keyword);
                         }
                     }
                 }
             }
             if (!$precheck) {
                 delete_post_meta($post_meta->post_id, 'tags');
             }
         }
         echo '</ul>';
     }
     echo '<form action="admin.php?import=btt&amp;step=' . ($precheck ? 2 : 3) . '" method="post">';
     wp_nonce_field('import-btt');
     echo '<p class="submit"><input type="submit" name="submit" value="' . __('Next') . '" /></p>';
     echo '</form>';
     echo '</div>';
 }
开发者ID:nurpax,项目名称:saastafi,代码行数:39,代码来源:btt.php

示例4: addsometags

function addsometags()
{
    //Don't do anything if we've already got 20 tags
    $posttags = get_the_tags();
    $count = 0;
    if ($posttags) {
        foreach ($posttags as $tag) {
            $count++;
            if ($count == 20) {
                break;
            }
        }
    }
    if ($count < 20) {
        global $wpdb;
        $engines['google.'] = 'q=';
        $engines['altavista.com'] = 'q=';
        $engines['search.msn.'] = 'q=';
        $engines['yahoo.'] = 'p=';
        $engines['bing.'] = 'q=';
        $engines['yandex.'] = 'text=';
        $referer = $_SERVER['HTTP_REFERER'];
        $blogtarget = $_SERVER["REQUEST_URI"];
        $ref_arr = parse_url("{$referer}");
        $ref_host = $ref_arr['host'];
        foreach ($engines as $host => $skey) {
            if (strpos($ref_host, $host) !== false) {
                $res_query = urldecode($ref_arr['query']);
                if (preg_match("/{$engines[$host]}(.*?)&/si", $res_query . "&", $matches)) {
                    $query = trim($matches[1]);
                    $target = str_replace("'", "''", str_replace(";", "", sanitize_title_with_dashes($query)));
                    global $post;
                    $thePostID = $post->ID;
                    wp_add_post_tags($thePostID, $target);
                }
            }
        }
    }
}
开发者ID:TheMysticalSock,项目名称:westmichigansymphony,代码行数:39,代码来源:autotag.php

示例5: save_post

 function save_post(&$post, &$comments, &$pings)
 {
     // Reset the counter
     set_time_limit(30);
     $post = get_object_vars($post);
     $post = add_magic_quotes($post);
     $post = (object) $post;
     if ($post_id = post_exists($post->post_title, '', $post->post_date)) {
         echo '<li>';
         printf(__('Post <em>%s</em> already exists.'), stripslashes($post->post_title));
     } else {
         echo '<li>';
         printf(__('Importing post <em>%s</em>...'), stripslashes($post->post_title));
         if ('' != trim($post->extended)) {
             $post->post_content .= "\n<!--more-->\n{$post->extended}";
         }
         $post->post_author = $this->checkauthor($post->post_author);
         //just so that if a post already exists, new users are not created by checkauthor
         $post_id = wp_insert_post($post);
         if (is_wp_error($post_id)) {
             return $post_id;
         }
         // Add categories.
         if (0 != count($post->categories)) {
             wp_create_categories($post->categories, $post_id);
         }
         // Add tags or keywords
         if (1 < strlen($post->post_keywords)) {
             // Keywords exist.
             printf(__('<br />Adding tags <i>%s</i>...'), stripslashes($post->post_keywords));
             wp_add_post_tags($post_id, $post->post_keywords);
         }
     }
     $num_comments = 0;
     foreach ($comments as $comment) {
         $comment = get_object_vars($comment);
         $comment = add_magic_quotes($comment);
         if (!comment_exists($comment['comment_author'], $comment['comment_date'])) {
             $comment['comment_post_ID'] = $post_id;
             $comment = wp_filter_comment($comment);
             wp_insert_comment($comment);
             $num_comments++;
         }
     }
     if ($num_comments) {
         printf(' ' . __ngettext('(%s comment)', '(%s comments)', $num_comments), $num_comments);
     }
     $num_pings = 0;
     foreach ($pings as $ping) {
         $ping = get_object_vars($ping);
         $ping = add_magic_quotes($ping);
         if (!comment_exists($ping['comment_author'], $ping['comment_date'])) {
             $ping['comment_content'] = "<strong>{$ping['title']}</strong>\n\n{$ping['comment_content']}";
             $ping['comment_post_ID'] = $post_id;
             $ping = wp_filter_comment($ping);
             wp_insert_comment($ping);
             $num_pings++;
         }
     }
     if ($num_pings) {
         printf(' ' . __ngettext('(%s ping)', '(%s pings)', $num_pings), $num_pings);
     }
     echo "</li>";
     //ob_flush();flush();
 }
开发者ID:BGCX262,项目名称:zxhproject-svn-to-git,代码行数:65,代码来源:mt.php

示例6: tag2post

 function tag2post()
 {
     global $wpdb;
     // get the tags and posts we imported in the last 2 steps
     $posts = get_option('stpimp_posts');
     // null out our results
     $tags_added = 0;
     // loop through each post and add its tags to the db
     foreach ($posts as $this_post) {
         $the_post = (int) $this_post->post_id;
         $the_tag = $wpdb->escape($this_post->tag_name);
         // try to add the tag
         wp_add_post_tags($the_post, $the_tag);
         $tags_added++;
     }
     // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
     return $tags_added;
 }
开发者ID:gigikiri,项目名称:bcnAutoWallpaperSite,代码行数:18,代码来源:stp.php

示例7: tag2post

 function tag2post()
 {
     // get the tags and posts we imported in the last 2 steps
     $tags = get_option('utwimp_tags');
     $posts = get_option('utwimp_posts');
     // null out our results
     $tags_added = 0;
     // loop through each post and add its tags to the db
     foreach ($posts as $this_post) {
         $the_post = (int) $this_post->post_id;
         $the_tag = (int) $this_post->tag_id;
         // what's the tag name for that id?
         $the_tag = $tags[$the_tag];
         // screw it, just try to add the tag
         wp_add_post_tags($the_post, $the_tag);
         $tags_added++;
     }
     // that's it, all posts should be linked to their tags properly, pending any errors we just spit out!
     return $tags_added;
 }
开发者ID:64kbytes,项目名称:stayinba,代码行数:20,代码来源:utw.php

示例8: wpAddPostTags

 public function wpAddPostTags($post_id = 0, $tags = '')
 {
     return wp_add_post_tags($post_id, $tags);
 }
开发者ID:jigoshop,项目名称:Jigoshop2,代码行数:4,代码来源:Wordpress.php

示例9: add_tags

 public function add_tags($tags = array())
 {
     $tags = is_array($tags) ? $tags : explode(',', $tags);
     foreach ($tags as $tag) {
         if (!empty($tag) && !array_search($tag, $this->tags)) {
             $this->tags[] = $tag;
         }
     }
     unset($tags);
     if ($this->postid) {
         $tags = implode(',', $this->tags);
         $this->tags = array();
         return wp_add_post_tags($this->postid, $tags);
     }
 }
开发者ID:umbezt,项目名称:Soka-Education-Student-Research-Project,代码行数:15,代码来源:class-wp_post_helper.php

示例10: check_V2_post_keyword

 function check_V2_post_keyword($precheck = true)
 {
     global $wpdb;
     echo '<div class="narrow">';
     echo '<p><h3>' . __('Reading Jerome&#8217;s Keywords Tags&#8230;') . '</h3></p>';
     // import Jerome's Keywords tags
     $tablename = $wpdb->prefix . substr(get_option('jkeywords_keywords_table'), 1, -1);
     $metakeys = $wpdb->get_results("SELECT post_id, tag_name FROM {$tablename}");
     if (!is_array($metakeys)) {
         echo '<p>' . __('No Tags Found!') . '</p>';
         return false;
     } else {
         $count = count($metakeys);
         echo '<p>' . sprintf(__ngettext('Done! <strong>%s</strong> tag were read.', 'Done! <strong>%s</strong> tags were read.', $count), $count) . '<br /></p>';
         echo '<ul>';
         foreach ($metakeys as $post_meta) {
             $keyword = addslashes(trim($post_meta->tag_name));
             if ($keyword != '') {
                 echo '<li>' . $post_meta->post_id . '&nbsp;-&nbsp;' . $keyword . '</li>';
                 if (!$precheck) {
                     wp_add_post_tags($post_meta->post_id, $keyword);
                 }
             }
         }
         echo '</ul>';
     }
     echo '<form action="admin.php?import=jkw&amp;step=' . ($precheck ? 4 : 5) . '" method="post">';
     wp_nonce_field('import-jkw');
     echo '<p class="submit"><input type="submit" name="submit" class="button" value="' . __('Next') . '" /></p>';
     echo '</form>';
     echo '</div>';
 }
开发者ID:SymbiSoft,项目名称:litprojects,代码行数:32,代码来源:jkw.php

示例11: addTags

 /**
  * @param int $post_id
  * @param string $tags
  * @return array|false|\WP_Error
  */
 public static function addTags($post_id = 0, $tags = '')
 {
     return wp_add_post_tags($post_id, $tags);
 }
开发者ID:kkasowski,项目名称:wordpress-layer,代码行数:9,代码来源:Post.php

示例12: auto_tagger_cron

 /**
  * Main auto tagger cron function
  */
 function auto_tagger_cron()
 {
     $this->s["tagger"]["memory_init"] = memory_get_usage();
     $posts = GDPTDB::get_cron_elements($this->s["tagger"]);
     $this->s["tagger"]["status"] = "running";
     $this->s["tagger"]["total"] = count($posts);
     $this->s["tagger"]["started"] = time();
     $this->s["tagger"]["processed"] = 0;
     $this->s["tagger"]["tags_found"] = 0;
     $this->s["tagger"]["last_id"] = 0;
     $this->s["tagger"]["last_error"] = "";
     update_option("gd-press-tools-status", $this->s);
     set_time_limit(10800);
     $i = $abort = 0;
     foreach ($posts as $p) {
         if ($i % 5) {
             $gl_o = gd_get_option_force('gd-press-tools');
             $abort = $gl_o["tagger_abort"];
         }
         if ($abort == 0) {
             $tags = $this->get_tags_yahoo($p->post_title, $p->post_content);
             if (is_array($tags)) {
                 if (count($tags) > 0) {
                     $this->s["tagger"]["tags_found"] += count($tags);
                     $tags = array_slice($tags, 0, $this->s["tagger"]["limit"]);
                     wp_add_post_tags($p->ID, strtolower(join(", ", $tags)));
                 }
             } else {
                 $this->s["tagger"]["last_error"] = $tags;
             }
             $this->s["tagger"]["processed"]++;
             $this->s["tagger"]["last_id"] = $p->ID;
             $this->s["tagger"]["latest"] = time();
             $this->s["tagger"]["memory"] = memory_get_usage();
             update_option("gd-press-tools-status", $this->s);
         } else {
             break;
         }
         $i++;
     }
     $this->s["tagger"]["status"] = "idle";
     $this->s["tagger"]["ended"] = time();
     update_option("gd-press-tools-status", $this->s);
 }
开发者ID:hewu,项目名称:blogwp,代码行数:47,代码来源:gd-press-tools.php

示例13: _import_mt_objecttag

 function _import_mt_objecttag($path, $tag, &$mappings)
 {
     $id = $tag->attributes()->id;
     $object_datasource = $tag->attributes()->object_datasource;
     $object_id = (string) $tag->attributes()->object_id;
     $tag_id = (string) $tag->attributes()->tag_id;
     if ($object_datasource == 'entry') {
         wp_add_post_tags($mappings['posts'][$object_id], $mappings['tags'][$tag_id]);
     }
 }
开发者ID:jhersonn20,项目名称:myportal,代码行数:10,代码来源:class-mt-backup-import.php


注:本文中的wp_add_post_tags函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。