Code Help - displaying custom taxonomy?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tittytweaker
    Confirmed User
    • Dec 2012
    • 184

    #1

    Code Help - displaying custom taxonomy?

    Hi guys. I created a custom taxonomy called "Model". As you can see from my home page, I've basically been using the tags to organize by model, but I decided to switch over. Now I just need to swap the code for "tags" with the code for "model", so that it displays underneath all the little pictures, as well as on the gallery page itself where it says "tags".

    Could someone take a look at my source code and tell me what exactly I need to change to accomplish this?

    Thanks in advance,
    ~TT
    www.tittytweaker.com
  • sarettah
    see you later, I'm gone
    • Oct 2002
    • 14293

    #2
    It is probably just a change in your template, which we cannot see, we can only see the output from whatever script you are running.

    .
    All cookies cleared!

    Comment

    • kasun0777
      Confirmed User
      • Nov 2012
      • 115

      #3
      Originally posted by sarettah
      It is probably just a change in your template, which we cannot see, we can only see the output from whatever script you are running.

      .
      yeah. great answer
      HIGH Conversion | YOUR Brand | NO hassles! Need we say more?
      Get your own cam site now.

      Comment

      • Tittytweaker
        Confirmed User
        • Dec 2012
        • 184

        #4
        http://www.adultsiteskins.com/

        I'm using the first pink theme on there. Should be able to download it and see what I'm seeing.
        www.tittytweaker.com

        Comment

        • sarettah
          see you later, I'm gone
          • Oct 2002
          • 14293

          #5
          Originally posted by Tittytweaker
          http://www.adultsiteskins.com/

          I'm using the first pink theme on there. Should be able to download it and see what I'm seeing.

          I hadn't noticed it was wp.

          Ok, in 10 or 12 files in the theme folder you will find <?php the_tags('Tags: ', ', ', ''); ?>

          Change that to <?php the_tags('Models: ', ', ', ''); ?>.

          .
          Last edited by sarettah; 02-10-2013, 06:30 AM.
          All cookies cleared!

          Comment

          • Tittytweaker
            Confirmed User
            • Dec 2012
            • 184

            #6
            That only changes the tags so that it says Models. I have a separate taxonomy set up called Models, and I want that to display there. I plan on utilizing the tags in addition to the custom taxonomy, so that's not going to work.
            www.tittytweaker.com

            Comment

            • sarettah
              see you later, I'm gone
              • Oct 2002
              • 14293

              #7
              Originally posted by Tittytweaker
              That only changes the tags so that it says Models. I have a separate taxonomy set up called Models, and I want that to display there. I plan on utilizing the tags in addition to the custom taxonomy, so that's not going to work.
              Well to do that within wp will probably not be easy and would probably require a programmer.

              I had read the original request that you were replacing the current tags with your new taxonomy so I figured you were putting your new taxonomy in place of the normal wp taxonomy.

              It seems to me that if you know enough to figure out how to do a new taxonomy within the database then you should be able to figure out how to get it to print out but maybe not.

              Anyway, without knowing your database structure on your new taxonomy I could not tell you anything about how to best implement it.

              .
              All cookies cleared!

              Comment

              • sarettah
                see you later, I'm gone
                • Oct 2002
                • 14293

                #8
                Continuing a bit.

                While I said above that I would not know without more info how best to implement it, and with a preface of "I am not a wp expert" I would reccomend:

                That you keep your modifications within the theme rather than modifying out the wp core. That way you will not lose your changes each month when you upgrade wp.

                So you would probably want to create a little library of your custom functions that deal with your new taxonomy then include it in the index.php (or archives, post, wherevere you are showing the new taxonomy) of your theme (wp-content/themes/yourtheme/index.php)

                Like so:

                <?php get_header(); ?>

                <?php
                // new taxonomy functions
                include('newtaxonomy.php');
                ?>

                Then wherever you are using it you would call your new function(s):

                <span><?php the_tags('Tags: ', ', ', ''); ?></span>

                <?php
                // print new taxonomy here ??
                echo my_new_taxonomy(get_the_ID(),arg2, arg3, arg4, etc);

                ?>

                Hope that helps.


                .
                Last edited by sarettah; 02-10-2013, 09:57 AM.
                All cookies cleared!

                Comment

                • Tittytweaker
                  Confirmed User
                  • Dec 2012
                  • 184

                  #9
                  Yeah, unfortunately I really know nothing about wordpress, only as much as I can glean from tutorials and weave in with my limited html/css knowledge. It was easy to create the custom taxonomy, I just don't know how to actually implement the taxonomy the same way the tags are implemented.

                  Code:
                  /**
                   * Add custom taxonomies
                   *
                   * Additional custom taxonomies can be defined here
                   * http://codex.wordpress.org/Function_Reference/register_taxonomy
                   */
                  function add_custom_taxonomies() {
                  	// Add new "Model" taxonomy to Posts
                  	register_taxonomy('model', 'post', array(
                  		// Hierarchical taxonomy (like categories)
                  		'hierarchical' => true,
                  		// This array of options controls the labels displayed in the WordPress Admin UI
                  		'labels' => array(
                  			'name' => _x( 'Model', 'taxonomy general name' ),
                  			'singular_name' => _x( 'Model', 'taxonomy singular name' ),
                  			'search_items' =>  __( 'Search Model' ),
                  			'all_items' => __( 'All Model' ),
                  			'parent_item' => __( 'Parent Model' ),
                  			'parent_item_colon' => __( 'Parent Model:' ),
                  			'edit_item' => __( 'Edit Model' ),
                  			'update_item' => __( 'Update Model' ),
                  			'add_new_item' => __( 'Add New Model' ),
                  			'new_item_name' => __( 'New Model Name' ),
                  			'menu_name' => __( 'Model' ),
                  		),
                  		// Control the slugs used for this taxonomy
                  		'rewrite' => array(
                  			'slug' => 'model', // This controls the base slug that will display before each term
                  			'with_front' => false, // Don't display the category base before "/model/"
                  			'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
                  		),
                  	));
                  }
                  add_action( 'init', 'add_custom_taxonomies', 0 );
                  
                  ?>
                  That right there is the actual chunk of code from my functions page. Is this all PHP code or something? That's something I'm entirely unfamiliar with.
                  www.tittytweaker.com

                  Comment

                  • sarettah
                    see you later, I'm gone
                    • Oct 2002
                    • 14293

                    #10
                    Originally posted by Tittytweaker
                    Yeah, unfortunately I really know nothing about wordpress, only as much as I can glean from tutorials and weave in with my limited html/css knowledge. It was easy to create the custom taxonomy, I just don't know how to actually implement the taxonomy the same way the tags are implemented.

                    .................

                    That right there is the actual chunk of code from my functions page. Is this all PHP code or
                    something? That's something I'm entirely unfamiliar with.
                    1. Yes that is php.

                    2. I did not know (as I said I am not a wp expert by any means) that they had a structured way to iintroduce a custom taxonomy. So you are doing it according to the book, that's good and probably better than the way I would have done it.

                    3. There should be information in the codex on how to use the custom taxonomy. I found a tutorial at http://net.tutsplus.com/tutorials/wo...om-taxonomies/ From what it says (and I am interpreting so my apologies if I do not have it right) you should be able to call your custom taxonomy thusly:

                    <?php

                    $model_list = get_the_term_list( $post->ID, 'model', '<strong>Model:</strong> ', ', ', '' );

                    // Output taxonomy information if there was any

                    if ( '' != $model_list ) {
                    echo $model_list;
                    } // endif

                    ?>

                    Something like that.

                    Now all that depends on you getting your taxonomy definition right and having your terms defined for the various posts.

                    If you need additional help I would suggest you hit up Fris or someone like that who is well versed in wp.

                    Have fun.

                    .
                    Last edited by sarettah; 02-10-2013, 11:07 AM.
                    All cookies cleared!

                    Comment

                    • Tittytweaker
                      Confirmed User
                      • Dec 2012
                      • 184

                      #11
                      Thanks for your help, seems to have done the trick.

                      Do you guys know how I would go about changing the template for that taxonomy? I have no idea where I'd go to edit that since creating a new taxonomy doesn't create an editable template in the theme, as far as I can tell. It seems if you make a new one it just pulls from a default template.

                      I'm doing my best to look these up for myself but since I'm for the most part unfamiliar with this I don't know what to look for specifically.
                      Last edited by Tittytweaker; 02-10-2013, 10:12 PM.
                      www.tittytweaker.com

                      Comment

                      • sarettah
                        see you later, I'm gone
                        • Oct 2002
                        • 14293

                        #12
                        Originally posted by Tittytweaker
                        Thanks for your help, seems to have done the trick.

                        Do you guys know how I would go about changing the template for that taxonomy? I have no idea where I'd go to edit that since creating a new taxonomy doesn't create an editable template in the theme, as far as I can tell. It seems if you make a new one it just pulls from a default template.

                        I'm doing my best to look these up for myself but since I'm for the most part unfamiliar with this I don't know what to look for specifically.
                        I am not sure what you are asking there.

                        What I gave you above is the code you would add to your theme in various places where you want the taxonomy to print. You are looking for something else?

                        If you could be a touch more specific about what template you are referring to I might be able to find something.

                        Sorry for being dense, coffee is just hitting the system now.

                        ;p

                        .
                        All cookies cleared!

                        Comment

                        • Tittytweaker
                          Confirmed User
                          • Dec 2012
                          • 184

                          #13
                          Basically, that code is just what makes it possible to display the taxonomy for that post, right? It's what outputs "Mode: Model Name".

                          Now when you click that model name, it takes you to a page with all the results for that model name. I'm trying to figure out how to edit that template, the same way one would edit the template for the category results page, or the tags results page.
                          www.tittytweaker.com

                          Comment

                          • sarettah
                            see you later, I'm gone
                            • Oct 2002
                            • 14293

                            #14
                            Originally posted by Tittytweaker
                            the same way one would edit the template for the category results page, or the tags results page.
                            That is the answer to your question. It is basically the same edit.

                            I took a look at your page and from what you have for Cristal Matthews I would say the edit for the page it goes to is pretty much the same. post->id is the post id and it appears that that is available on the page it goes to when you click.

                            Should be available on your gallery page too.

                            Search through all the .php pages in the theme for where it uses the tags code and you should be able to add your new code beneath it or in place of it.

                            .
                            All cookies cleared!

                            Comment

                            • Tittytweaker
                              Confirmed User
                              • Dec 2012
                              • 184

                              #15
                              No, that's not what I'm talking about. I'm not talking about the text underneath the photos anymore. I'm talking about the whole template for the whole page that clicking the model name takes you to. I can't edit that page because when you create a new taxonomy it doesn't add a new template for that page to the theme, therefore I can't edit anything for that page.
                              Last edited by Tittytweaker; 02-11-2013, 09:38 AM.
                              www.tittytweaker.com

                              Comment

                              • sarettah
                                see you later, I'm gone
                                • Oct 2002
                                • 14293

                                #16
                                Originally posted by Tittytweaker
                                No, that's not what I'm talking about. I'm not talking about the code underneath the photos. I'm talking about the whole template for the whole page that clicking the model name takes you to. I have no clue how to edit that page because when you create a new taxonomy it doesn't add a new template for that page to the theme.
                                It is using an existing template. It did not invent anything new, I don't think ;p

                                I will take a glance and see if I can figure out which one. Probably category.php

                                In your category.php in your theme folder under this line:

                                <span><?php the_tags('Tags: ', ', ', ''); ?></span>

                                Put this:

                                <?php echo 'This is the category template'; ?>

                                then click through to the page in question and see if that line shows up. Depending on your font defaults and stuff you might have to do a view source to see it as it can end up black on black or white on white.

                                If it shows up, then it is the category.php file that you need to edit for that page. That is why I said to edit all occurrences throughout all the template files.

                                Let me know what happens please.


                                Edited in: I just went through the files in your theme, (yes, I actually downloaded it yesterday). The page template for that is either the category.php or the tag.php template files.

                                In the tag.php go and so the same edit as above but this one say <?php echo 'This is the tage page'; ?> and then click through and see if it says that on the page.

                                Those appear to be the only 2 templates in there that do not have the "related galleries" in them. Since the "related galleries" is NOT showing on the page I think it is one of them.

                                Hope that helps.

                                .
                                .
                                Last edited by sarettah; 02-11-2013, 09:56 AM.
                                All cookies cleared!

                                Comment

                                • Tittytweaker
                                  Confirmed User
                                  • Dec 2012
                                  • 184

                                  #17
                                  Ah! Found it. It was the archives template. I'd already changed the tags and category template so I wasn't sure what else there was to change. Thanks for your help, and for tolerating me! lol
                                  www.tittytweaker.com

                                  Comment

                                  • sarettah
                                    see you later, I'm gone
                                    • Oct 2002
                                    • 14293

                                    #18
                                    Originally posted by Tittytweaker
                                    Ah! Found it. It was the archives template. I'd already changed the tags and category template so I wasn't sure what else there was to change. Thanks for your help, and for tolerating me! lol
                                    Actually, that's funny because yesterday I had tried to edit the message I posted to say that it could be archives too. But the edit didn't take and I decided, nah, it ewouldn't be the archives template, doesn't make sense.

                                    Glad you got it worked out.


                                    .
                                    All cookies cleared!

                                    Comment

                                    Working...