Forum Replies Created

Viewing 15 replies - 1 through 15 (of 25 total)
  • Thread Starter zebrastribe

    (@zebrastribe)

    Hi Dan
    Thank you for the quick reply it worked perfectly…

    Great plugin by the way ??

    Thread Starter zebrastribe

    (@zebrastribe)

    oh my …stupid me and my fat fingers.

    this seems to work:

    <?php
    $taxonomy = 'category';
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    $post_terms_ex = array (1);
    $result_post=array_diff($post_terms, $post_terms_ex);
    
    // separator between links
    $separator = ', ';
    
    if ( !empty( $result_post ) && !is_wp_error( $result_post ) ) {
    
    	$term_ids = implode( ',' , $result_post);
    	$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
    	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    
    	// display post categories
    	echo $terms;
    
    }
    ?>

    Is there a better way then is code?

    when I google “array_diff()” it seems that a lot of posts is about that is slow on large arrays. How large is large?

    Thread Starter zebrastribe

    (@zebrastribe)

    Tried this but it does not work…

    <?php
    $taxonomy = 'category';
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    // separator between links
    $separator = ', ';
    
    if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
    
    	$term_ids = implode( ',' , $post_terms );
    	$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
    	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    	$terms_ex = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=1' );
    	$terms_ex = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    
    	// display post categories
    	$result=array_diff($terms_ex,$terms);
    	echo $result;
    }
    ?>
    Thread Starter zebrastribe

    (@zebrastribe)

    Thanx bcworkz.
    How would the new code look with the array_diff() if I used the standard code from the codex

    <?php
    $taxonomy = 'category';
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    // separator between links
    $separator = ', ';
    
    if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
    
    	$term_ids = implode( ',' , $post_terms );
    	$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
    	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    
    	// display post categories
    	echo  $terms;
    }
    ?>
    Thread Starter zebrastribe

    (@zebrastribe)

    Can I may make the exclude on:

    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );

    so that the categories do not show up in the list?

    Thread Starter zebrastribe

    (@zebrastribe)

    Well, I think it is because it shows some errors from yesterday…

    <?php
    $taxonomy = 'category';
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    // separator between links
    $separator = ', ';
    
    if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
    
    $term_ids = implode( ',' , $post_terms );
    $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&exclude=1' . '&include=' . $term_ids );
    $terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );
    
    // display post categories
    echo  $terms;
    										}									
    
    									?>

    And this is showing the right two categories for this specific post on index.php

    Thread Starter zebrastribe

    (@zebrastribe)

    Okay. I am on mamp and the php_error.log does not show an error?

    Thread Starter zebrastribe

    (@zebrastribe)

    Sorry. The categories is not outputted at all and the space is left blank

    Thread Starter zebrastribe

    (@zebrastribe)

    I tried:
    1.

    <?php
    $taxonomy = 'category';
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    // separator between links
    $separator = ', ';
    
    if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
    
    	$term_ids = implode( ',' , $post_terms );
    	echo '<pre>';
    	print_r($term_ids);
    	echo '</pre>';
    
    	$terms = wp_list_categories( 'title_li=&style=none&echo=0&include=' . $term_ids );
    	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    
    	// display post categories
    	echo  $terms;
    }									
    
    									?>

    and

    2.

    <?php 
    
    // get the term IDs assigned to post.
    $post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
    // separator between links
    $separator = ', ';
    
    if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {
    
    	$term_ids = implode( ',' , $post_terms );
    	echo '
    <pre>';
    	print_r($term_ids);
    	echo '</pre>
    ';
    
    	$terms = wp_list_categories( 'title_li=&style=none&echo=0&include=' . $term_ids );
    	$terms = rtrim( trim( str_replace( '',  $separator, $terms ) ), $separator );
    
    	// display post categories
    	echo  $terms;
    }									
    
    									?>

    with the first piece of code it shows 7, 1, Features, Uncategorized in a list with 7,1 inside the “pre” tag without a link.
    (it is the right categories for this posts and there IDs)

    The second does not work..

    Thread Starter zebrastribe

    (@zebrastribe)

    No. Howto?

    I got this from the codex:
    exclude
    (string) Exclude one or more categories from the results. This parameter takes a comma-separated list of category ids. The parameter include must be empty

    And the example is like this:
    $terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );

    is the include parameter empty if?
    ‘&include=’ . $term_ids

    Thread Starter zebrastribe

    (@zebrastribe)

    All the categories from the whole site is shown and the “1” is excluded.

    What I need is:
    Only the associated (to the post) categories with “1” excluded.
    Like this from the codex
    But I need to exclude one or more…

    Thread Starter zebrastribe

    (@zebrastribe)

    Yes. I also need to specify more categories later. Maybe as a variable $exclude_cat?

    Forum: Networking WordPress
    In reply to: Media url
    Thread Starter zebrastribe

    (@zebrastribe)

    ok. I see you point and thank you for explanation, sorry for my ignorance…

    Which is the best procedure for updating the links inside the post?

    Because now the new images are placed into “wp-content/uploads/sites/2/” and the old are with the “/files/” (which is in the “wp-content/uploads/sites/2/” folder)

    At the moment the old is on domain.com and the new is on sub.domain.com but when all is up and running I will make the switch.

    You talk about search/replace?

    Forum: Networking WordPress
    In reply to: Media url
    Thread Starter zebrastribe

    (@zebrastribe)

    Hi Mika

    Ok. The custom land is not the way for me…

    Why does the old install exclude the “wp-content/blogs.dir/2/” from visitors url?
    when the new install does not hide the “wp-content/uploads/sites/2/?

    I guess I hoped that there were some magic htaccess rewrite rule that could make it work…

    Instead of having to relay on this plugin:

    https://codecanyon.net/item/hide-my-wp-no-one-can-know-you-use-wordpress/4177158

    Forum: Networking WordPress
    In reply to: Media url
    Thread Starter zebrastribe

    (@zebrastribe)

    Hi Mika

    Thank you for your reply. I understand that the new way of placing the files is in the “uploads”-folder and I have no problem with the files being there but I would really like to have the url for the visitor as clean as possible and not include the wp-content/uploads/sites/ or /blogs.dir/

    Like
    https://domain.com/media/2008/06/image.jpg

    Can I be done?

    If I understand you correctly you are talking about updating the database from “/files/” to “sites/2”, right?

    Then the url will look like:
    https://domain.com/wp-content/uploads/sites/2/2014/02/image.jpg

    Can the “wp-content/uploads/sites/” part be just f.ex “media”?
    As I have seen the in roots.oi theme?

Viewing 15 replies - 1 through 15 (of 25 total)