Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter tgildred

    (@tgildred)

    Hey…. I think I did it! Thanks to the advice from t31os_ and going back to Justin Tadlock’s page and comparing notes, I rewrote the line as:

    elseif (is_taxonomy($taxonomy)) $archive_display_name = get_query_var( 'term' );

    And it ****** worked. I’m so excited right now. Any problems with that approach? Seems like it works, so I’m going with it for now. Thanks for the help!

    Thread Starter tgildred

    (@tgildred)

    Thanks to the advice, I’m nearly there. Both is_tax() and is_taxonomy($taxonomy) seem to work, in that they return the title as “posts tagged with” (don’t read too much into the word “tagged” here, I just haven’t changed it from the default text that came with my theme yet). So, it seems to recognize the “elseif (is_taxonomy($taxonomy)) bit. I just need to figure out what to define $archive_display_name for that statement.

    In other words:

    if (is_category()) $archive_display_name = single_cat_title('', false);
    elseif (is_tag()) $archive_display_name = single_tag_title('', false);
    elseif (is_taxonomy($taxonomy)) $archive_display_name = ????????????;
    ..... etc.

    I know it must be possible, because the correct term is used for the page title. I just have not yet been able to figure out how…

    Thread Starter tgildred

    (@tgildred)

    Small update to my last post: I changed

    ‘rewrite’ => true

    to

    ‘rewrite’ => false

    And it magically worked. I have no idea why. As I’d like to have the prettier links, I guess my original question still stands. I should note that I’m developing this thing on a local host, so the “pretty” URL rewrite looks like this “http://localhost:8888media_type/magazine” and the “ugly” non-rewritten URL is “http://localhost:8888/?media_type=magazine”

    I wonder if once this is live, the problem will go away? I’ll also add this question: is there a custom taxonomy equivalent of “is_category” and “single_cat_title”?

    Many thanks.

    Thread Starter tgildred

    (@tgildred)

    Hi… thanks for the feedback. Both of these seem very promising, but I think custom taxonomies is exactly what I’m looking for. I’ve read the posts about custom taxonomy at the web site provided above and have read numerous other articles about this, and have successfully enabled my custom taxonomy by adding the following to my functions.php file:

    <?php
    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
    	register_taxonomy( 'media_type', 'post', array( 'hierarchical' => false, 'label' => 'Media Type', 'query_var' => true, 'rewrite' => true ) );
    	register_taxonomy( 'client', 'post', array( 'hierarchical' => false, 'label' => 'Client', 'query_var' => true, 'rewrite' => true ) );
    	register_taxonomy( 'project', 'post', array( 'hierarchical' => false, 'label' => 'Project	', 'query_var' => true, 'rewrite' => true ) );
    }
    ?>

    I then added the following code to single.php:

    <br /><?php echo get_the_term_list( $post->ID, 'media_type', 'Media Type: ', ', ', '' ); ?>

    Otherwise, single.php is the same as the code in my original post. What I can’t figure out is how to get that to output all posts with a media_type: magazine to my archive.php. I’ve tried numerous changes to my archive.php code, but for simplicity’s sake, please see my original post for my archive.php code, since my attempts were just shots in the dark. Any thoughts? I’m sure I’m missing something simple. I hope, anyway. Thanks again for the help, and in advance for any forthcoming help. 🙂

Viewing 4 replies - 1 through 4 (of 4 total)