Tagged: x
-
AuthorPosts
-
September 15, 2016 at 6:55 pm #1177346
pcrossnzParticipantHi X-theme team!
I’m stuck with a rather simple problem. I’d like to display the categories of a post along with it’s title in the post. For example, you’s open the post and be greeted with “categories”, then “blog title” followed by featured image and then content. I’m using a frontend post plugin so I’d need to do this so it pops up automatically.
Any ideas?
Thanks for your time!
Phil
September 15, 2016 at 11:35 pm #1177707
RupokMemberHi Phil,
You can try our Recent Posts element where you can specify the category.
Thanks!
September 22, 2016 at 4:19 pm #1187021
pcrossnzParticipantHi. Thanks for your response and sorry for the delay getting back to you! I’ve certainly used the recent posts setting in the past. But thats not what I’m after here. I have posts listed under categories and child categories etc, each with their own tags. I’d like to display the post categories (that were selected for that post) on the post itself automatically. For example, under the post title in H2 or 3. That way, the posts own categories become part of the post title. I thiught it would be an easy fix but I cant seem to find anything. Any help appreciated! Picture attached
September 22, 2016 at 4:22 pm #1187024
pcrossnzParticipantOne more thing! It would be awesome if we could display the categories as:
Parent Category/child category/child of child category
I know this isn’t a major for you guys but I’m pretty stuck here! Thanks for all your help!
Phil
September 22, 2016 at 9:10 pm #1187379
LelyModeratorHello Phil,
Thanks for writing in! To assist you with this issue, we’ll first need you to provide us with your URL where you want this to implement. This is to ensure that we can provide you with a tailored answer to your situation. Once you have provided us with your URL, we will be happy to assist you with everything.
September 22, 2016 at 11:47 pm #1187491
pcrossnzParticipantHi there,
No problems! Check out myriver.nz/example-log/
This is an example of what a user submitted post will look like. Only, at the top, under “example log” I’d love to display the post categories. Any assistance appreciated!
Phil
September 23, 2016 at 12:57 am #1187538
Paul RModeratorHi Phil,
To achieve that, you can add this in your child theme’s functions.php file (wp-content/themes/x-child/functions.php)
function x_icon_entry_meta() { $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); // // Categories. // if ( get_post_type() == 'x-portfolio' ) { if ( has_term( '', 'portfolio-category', NULL ) ) { $categories = get_the_terms( get_the_ID(), 'portfolio-category' ); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_term_link( $category->slug, 'portfolio-category' ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark" data-x-icon=""></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } else { $categories_list = ''; } } else { $categories = get_the_category(); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark" data-x-icon=""></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s</p>', $date, $categories_list ); } }You may add it after this line
// Additional Functions
// =============================================================================Hope that helps.
September 25, 2016 at 2:36 am #1189599
pcrossnzParticipantHi Paul,
That’s amazing thank you! I’ve put this through on the site and I’m thinking we’re almost there!
Would it be possible to get rid of the tag icons and add a little padding to the top of the category list? I also wonder if it’s possible to have the child themes displayed after the parent themes? I’m not sure if this is even a possibility but right now they just appear to be in alphabetical order.
Thanks so much for your help! Any advice/help appreciated 🙂
http://myriver.nz/its-great-to-be-on-granity/
Phil
September 25, 2016 at 2:47 am #1189604
ChristopherModeratorHi there,
Please add following code in Customize -> Custom -> CSS :
p.p-meta span:nth-child(2) i { display: none; } p.p-meta span:nth-child(2) { margin-top: 17px; }I also wonder if it’s possible to have the child themes displayed after the parent themes?
Are you referring to list of themes in WP dashboard? Regretfully this isn’t a feature offered by X. It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this.
Hope it helps.
September 25, 2016 at 2:38 pm #1189956
pcrossnzParticipantThanks for your help!
September 25, 2016 at 5:32 pm #1190053
RadModeratorYou’re welcome!
November 27, 2016 at 2:14 am #1271971
pcrossnzParticipantHi again!
I’m really loving this feature thanks. But I wonder if it will be possible to add in another category of a custom taxonomy (such as a custom category made with the pods plugin)?
Can this code be easily modified to add in another taxonomy?
Thanks again for your help!
Phil
November 27, 2016 at 2:19 am #1271974
ChristopherModeratorThanks for writing in! Regretfully, at this time I am not entirely certain what it is you would like to accomplish based on the information given in your post. If you wouldn’t mind providing us with a little more clarification on what it is you’re wanting to do (a link to a similar example site would be very helpful, or perhaps some screenshots), we’ll be happy to provide you with a response once we have a better understanding of the situation.
November 27, 2016 at 10:33 pm #1272712
pcrossnzParticipantHi Christopher,
Thanks for your response. Here’s a link to a particular post of interest:
http://myriver.nz/its-great-to-be-on-granity/
You’ll notice that after we put in the particular modifications described above, I now have post categories below my title. This is awesome! However, I’d like to add in some additional custom taxonomies to these posts. So, instead of just having categories and tags, I will also have “regions”, “grades”, “rivers” etc.
I am using the pods plugin to create these taxonomies, and it works well to do this. However, I’d like to, if possible, add the additional taxonomy data to what we already have (see attached picture).
I have since read that this is possible with using get_the_terms, rather than get_the_category. Can we modify the code above to get all terms? Sorry, I’m a total amateur here…
Any help appreciated! Thanks again
Phil
November 27, 2016 at 11:01 pm #1272735
Rue NelModeratorHello There,
Thanks for updating us in! We do not know how you can display the custom taxononies with pods plugin. It could be by a php code or by using a shortcode. You can simply update the given code in your child theme’s functions.php file
function x_icon_entry_meta() { $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ); // // Categories. // if ( get_post_type() == 'x-portfolio' ) { if ( has_term( '', 'portfolio-category', NULL ) ) { $categories = get_the_terms( get_the_ID(), 'portfolio-category' ); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_term_link( $category->slug, 'portfolio-category' ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark" data-x-icon=""></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } else { $categories_list = ''; } } else { $categories = get_the_category(); $separator = ', '; $categories_output = ''; foreach ( $categories as $category ) { $categories_output .= '<a href="' . get_category_link( $category->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in: “%s”", '__x__' ), $category->name ) ) . '"><i class="x-icon-bookmark" data-x-icon=""></i> ' . $category->name . '</a>' . $separator; } $categories_list = sprintf( '<span>%s</span>', trim( $categories_output, $separator ) ); } // // Display Custom taxonomies // // Please ask assistance from the creators of Pods plugin // to know how to display the taxonomies // $custom_tax = ''; if ( x_does_not_need_entry_meta() ) { return; } else { printf( '<p class="p-meta">%1$s%2$s</p>', $date, $categories_list, $custom_tax ); } }You will need to ask assistance from the creators of Pods plugin to know how to display the custom taxonomies in your site.
As this is all custom development, regretfully we won’t be able to assist further. Custom development is outside the scope of our support. We’re happy to provide advice and get you started in the right direction, but you would still be responsible for the implementation.
Thank you for your understanding.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1177346 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
