Strange question which is typically against how Wordpress works but I'm wanting to add additional names to a category, almost like a "also known as".
So might have "Tech talk" as what the category is called but wanting to add "Bob Billy" (for example) as what the category can also be known as. I know about sub categories and this isn't what I mean.
Thanks.
In wordpress categories, have description. you can use the description and show it anywhere on your blog/website. this is the case where you have just one alternative for each category and not more.
According to the documentation:
<?php echo category_description( $category_id ); ?>
Returns the description of a category defined in the category settings screen for the current category (Posts > Categories).
Please let me know if it fits your needs, or I will hand you another way to acomplish that :)
Related
I wonder if it is possible to assign two routes to the same category. For example:
By accessing http://myblog.com/action or http://myblog.com/movie-action, leads me to the same category destination.
Thank you
i Think this plugin can handle this
http://wordpress.org/plugins/quick-pagepost-redirect-plugin/
it makes all kind of redirections in wordpress
One way to do this is to make all posts have both categories and then the links come up the same.
However, to do literally what you are asking, let's say you want to get to Category Action through Category Movie Action. See making categories in the Codex.
Create a .php file for the category you want to redirect. In this, make
category-movie-action.php
In this file, you can just paste the code
<?php
header( 'Location: http://myblog.com/action' ) ;
?>
And that should redirect anyone who goes to that particular category. If you need a more elegant solution I'm sure there are ways as well.
I'm trying to accomplish a three-step page hierarchy in Wordpress.
Here's an example of what a breadcrumb navigation might look like:
Mathematics > Algebra > Variables
I've got a page that lists all of my top-level categories:
<?php wp_list_categories('depth=1'); ?>
What I need next is to make it so when you click a category, it links you to a page that just lists all of its subcategories. By default it takes you to a page with every post in that category.
So you could select say Math on the first page, followed by a page with sub-categories like Arithmetic, Algebra, Geometry, and then when you select your sub-cat it takes you to the posts.
I'm open to using any alternative methods too if you've any ideas on a better way to do it. Using the built-in category system just seemed most appropriate.
wp_list_categories can take an argument, 'child_of', that will return a list of child categories. So, in your individual category listing page, you can use the category id of the relevant category to retrieve the children like this:
<?php $children = wp_list_categories('child_of='.$your_category->cat_ID); ?>
Further documentation for wp_list_categories can be found here: http://codex.wordpress.org/Template_Tags/wp_list_categories
I to allow my users to sort the list of wordpress posts by Title, Date added, Comments, Rating etc. These will all be buttons or links at the top of the list (kinda like table view sorting)
However, I have no PHP experience and only know a few basics. How would I achieve this? I currently use the following line to sort my posts by name ASC:
<?php query_posts( $query_string . "&orderby=title&order=ASC" ); ?>
I was personally thinking of the following solution: orderby=VARIABLE1&order=VARIABLE2
Where VARIABLE1 would be set to title by default and VARIABLE2 would be set ASC by default. However I don't know if this is the best solution, and I know even less on how to achieve this.
Thanks for any future help!
Swen, attach ?orderby=title or ?orderby=date to the URLs of your buttons, WordPress will do the ordering itself.
One of the easiest way is just to use the Post Types Order plugin
How am I able to show a single term of a custom taxonomy in Wordpress?
I have a custom taxonomy, which will always have only one term in it, and I want to display it in a custom loop on my home page. I have tried all possible ways, with one (blargh, can't remember which one) I managed to display the term but as a link, which I don't want. I need it as regular text, since I want to display it in my own href, which will link to the place where I want to.
Any ideas anyone? All and any help very much appreciated. This issue is slowing down my development of a custom theme. :(
Get the single term object using get_term($term_ID, $taxonomy), or alternatively get_term_by('slug', $term_slug, $taxonomy).
The term object will have, among other properties;
$term->name; // the name of the term!
$term->slug;
$term->term_id;
$term->count; // number of objects using the term
I'm setting up a WordPress installation where I want some of the articles to show the date they were posted, and other articles to leave the date out. I'd like these articles to be completely dateless, if possible, so they only show in category archives and not in date archives.
I'm guessing I can tweak the templates to show the date or not based on the article's category, I was wondering if there was an easier solution to this?
Or should I start writing my own plugin to do this?
I've not got anything online at the moment, this is just an idea I'm churning over in my head for now.
Cheers,
Dan
Your theory of how to do it (have the theme files make a check for the category, then either display the date or not) is correct.
I think this code should do it:
<?php
if (is_category('CategoryThatDisplaysDates')) {
echo '<p>Date posted: '; the_date(); echo '</p>';
};
?>
If you don't want to mess up your categories (having “CategoryThatDisplaysDates” in a category listing looks a bit weird), you could try custom fields (meta-data). You add a custom field, e.g. display-date, in the write post panel and set its content to true.
Then, use ahockley's code, just change if(is_category(...)) to
if(get_post_meta($post->ID, 'display-date', true) == 'true')
i'd go with a custom field. you can read about using custom fields here: http://codex.wordpress.org/Using_Custom_Fields