<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>WordPress DK Forum Topic: Fjern term fra special post type før version 3.6</title>
		<link>http://wp-danmark.dk/forum/topic/fjern-term-fra-special-post-type-f%c3%b8r-version-36</link>
		<description>WordPress DK Forum Topic: Fjern term fra special post type før version 3.6</description>
		<language>da-DK</language>
		<pubDate>Fri, 26 Jun 2026 10:30:22 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Søg]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://wp-danmark.dk/forum/search.php</link>
		</textInput>
		<atom:link href="http://wp-danmark.dk/forum/rss/topic/fjern-term-fra-special-post-type-f%c3%b8r-version-36" rel="self" type="application/rss+xml" />

		<item>
			<title>René Skou om "Fjern term fra special post type før version 3.6"</title>
			<link>http://wp-danmark.dk/forum/topic/fjern-term-fra-special-post-type-f%c3%b8r-version-36#post-51110</link>
			<pubDate>ons, 09 okt 2013 14:07:58 +0000</pubDate>
			<dc:creator>René Skou</dc:creator>
			<guid isPermaLink="false">51110@http://wp-danmark.dk/forum/</guid>
			<description>&#60;p&#62;Hejsa gutter&#60;/p&#62;
&#60;p&#62;Jeg håber en af jer kan hjælpe mig med en ting.&#60;/p&#62;
&#60;p&#62;Jeg har skrevet et plugin det via en ajax funktion fjerner et term fra et woocommerce product, efter wp version 3.6 er der en funktion &#34;wp_remove_object_term&#34; men før wp version 3.6 findes der ingen funktion.&#60;/p&#62;
&#60;p&#62;Lige nu bruger jeg denne hjælpe funktion &#60;code&#62;&#60;br /&#62;
/**&#60;br /&#62;
 * Remove a given term from the specified post&#60;br /&#62;
 *&#60;br /&#62;
 * Helper function since this functionality doesn't exist in core&#60;br /&#62;
 */&#60;br /&#62;
function rsj_remove_object_term( $post_id, $term, $taxonomy ) {&#60;/p&#62;
&#60;p&#62;	if ( ! is_numeric( $term ) ) {&#60;br /&#62;
		$term = get_term( $term, $taxonomy );&#60;br /&#62;
		if ( ! $term &#124;&#124; is_wp_error( $term ) )&#60;br /&#62;
			return false;&#60;br /&#62;
		$term_id = $term-&#38;gt;term_id;&#60;br /&#62;
	} else {&#60;br /&#62;
		$term_id = $term;&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	// Get the existing terms and only keep the ones we don't want removed&#60;br /&#62;
	$new_terms = array();&#60;br /&#62;
	$current_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' =&#38;gt; 'ids' ) );&#60;/p&#62;
&#60;p&#62;	foreach ( $current_terms as $current_term ) {&#60;br /&#62;
		if ( $current_term != $term_id )&#60;br /&#62;
			$new_terms[] = intval( $current_term );&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;	return wp_set_object_terms( $post_id, $new_terms, $taxonomy );&#60;br /&#62;
}&#60;br /&#62;
&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Men findes der en bedre funktion, da denne her looper igennem alle terms, hvilket er en tung opgave?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
