SEO & WordPress: Changing category links manually - wordpress

I'm not too sure about SEO on WordPress as I read somewhere (I think) that Google penalises category pages for duplication and was hoping someone could tell me whether or not it's a good idea to cut out the links to the category pages all together?
My permalink structure for my main navigation does not link to the category pages. I have created a page specifically for tutorials like so:
myurl.com/tutorials/tutorial-type
and then on the pages there is an if-statement that gets posts from a specified category for that page.
so myurl.com/tutorials/tutorial-type will get only posts in the tutorial-type category.
What i'm planning is instead of using the:
<?php the_category(', '); ?>
in the typical Posted in: Tutorials format under the title of the post to a quick function that will direct someone to the main page for that category. like so:
function changeCategoryToPage() {
if (in_category( 'tutorial-type' )) { ?>
Tutorial Type
<?php }
}
I would appreciate your feedback and wisdom :)

Related

wordpress get current permalink or url without domain

I'm not sure if I titled this correctly but this is my issue, I have to create 2 same exact blogs and the only difference is language. So but what I need is at the top when clicked on a language it would take the user to that same page but in the language he/she clicked on.
I'm using permalinks currently and I've tried the following:
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(get_option('home')));
}
my_permalink();
?>
but that for some reason on my home page points to a post and not the home page. I believe that works in posts but I need that to also work on the home. Here's the links to both blogs, any help is much appreciated..
English: http://www.inblu.pe/prblog/
Spanish: http://www.inblu.pe/prbloges/
It could be more simple with standard PHP method :
$_SERVER["REQUEST_URI"]
Of course it will work for current post only.
You can also use that :
<?php
function my_permalink() {
echo substr(get_permalink(), strlen(home_url('/')));
}
my_permalink();
?>
How about the_permalink? I'm fighting with that now.
~ Justin

WORDPRESS: Disable comments in "News" Category and Enable in "Blog" Category?

I have a News page that displays all the posts within the "News" Category. This category has sub-categories such as "Merchandise, Music, Events" ect.
I am aiming to remove comments from ALL News/Sub-category posts but only display them with the "Blog" Category posts.
Right now I have my single.php set up so posts with the "Gallery" post_format structure are displayed differently.
Here is the single.php file//
http://pastebin.com/YNf3TxT6
I am wondering what I have to fix in order to get this working...
Edit: For future viewers, here is the updated paste from the conversation below for a single.php that will only show the comments template if the post is in the "Blog" Category: pastebin.com/y9ZtCN5U
Assuming you put your Blog posts on a page separate from your news posts, you should be able to use different templates based on category.
http://codex.wordpress.org/Category_Templates
So, you could make a category-blog.php template file that doesn't include the comments code.
If all of your categories are being listed on the same page, use this instead of the in_category stuff on line 50.
<?php
foreach (get_the_category() as $category) {
if ( $category->name == 'Blog' ) {
comments_template();
}
}
?>
Not 100% sure that will work, but try it out and let me know what happens.

WordPress--post only latest 1 or 2 or 3 posts on homepage

How do I just display the latest post on home (not the whole archive as wp does by default)?
And how can I influence that it has/not date, category, read more, etc?
WP manual does not explain this clearly. Or does it? If yes, please tell me where?
Thank you guys! And girls!
The new Wordpress Themes have child themes, it is a new way to organize and simplify upgrading themes, but it can be a pain because they are not as easy to modify as older themes. Anyway, there is the old way:
You can use the settings in the Administration Page to set your homepage to display only one post (Settings / Reading / Blog pages show at most -> 1 post). But if you want just your home to display one post, and decide you want your archives to display the basic 10 posts, you can edit your theme template to use this function:
<?php query_posts('posts_per_page=1'); ?>
Function Reference/query posts
http://codex.wordpress.org/Function_Reference/query_posts
To be sure no date or category is displayed, you also have to edit the template and remove the corresponding php code (in the loop, you should look for these functions:
<?php the_category(); ?>
<?php the_date(); ?>
Function Reference/the category
http://codex.wordpress.org/Function_Reference/the_category
Function Reference/the date
http://codex.wordpress.org/Function_Reference/the_date
To use the new way, you have to create a child theme to your theme, and override the loop by creating your own loop.
Chld Themes
http://codex.wordpress.org/Child_Themes

How to Display Nice URL for Wordpress Category Page?

I have a site whose home page shows a single Wordpress category page. I'm using a custom theme and the index.php file there does a 301 redirect to "mysitename.com/?cat=3". This page is generated with an event calendar plugin and a lot of custom code. It works, but the displayed URL is "mysitename.com/?cat=3" which I'd prefer my visitors not see; I'd rather have the URL be just "mysitename.com", "mysitename.com/index.php", or even "mysitename.com/calendar".
The visitor can view "prev month" and "next month", which result in URLs like "mysitename.com?cat=3&eventDate=2010-07&bt=a" -- still within the same category but with additional parameters in the URL. (I am OK having a more convoluted URL like this shown to my visitors on previous/next month; it's just the initial page URL I'd like to be nicer.)
I've messed around with the permalinks but can't get nice URLs to work correctly that way. Is there an .htaccess way to do this?
In the "permalinks" section under the "Settings" tab, you can add a category base to the categories.
Thus if you have a category base of "category" and a category name "Cool Stuff" with a slug of "cool_stuff"
Your category link would link like this depending on your permalink settings.
http://yoursite.com/category/cool_stuff/
Okay. My Last answer was not base on your "edited question".
If you remove the 301 redirect to "mysitename.com/?cat=3"
you can edit the index.php file.
This will most likely take care of your url issue.
You can edit the loop to show only categories from id: 3
Thus, you will make a querypost for category 3 as follow:
<?php query_posts('showposts=9'); ?>
See Query Post # Wordpress for more info.
Put this before the loop.
The coding may look like this:
<?php query_posts('cat=3'); ?>
<?php if (have_posts()) {?>
<?php while (have_posts()) : the_post(); ?>
<li>
<?php the_title(); ?>
<span style="float: right;"><?php the_time('m/d/y'); ?></span>
</li>
<?php endwhile; }?>
You could use .htaccess to map mywebsite.com/calendar to mywebsite/?cat=3, but WordPress will still look at the original url to find out which category to use, so this will not work.
I suggest you look in the code of the plugin to find out how it gets the current category, and maybe trick it (by an extra call to query_posts('cat=3')) to think we are looking at the url for category 3 (you don't need to display the posts, just do the query). You can even do this on your homepage (but maybe use home.php, not index.php, since the latter is a fallback for other template pages), so you don't need a redirect. But the key is that you need to look at the code of your plugin (can you tell us the name?) to find out how it works.

adding single.php page to wordpress or if condition for main page or post detail page

I use Barecity Theme for WordPress. i built everything, but now i need to add a single.php file to theme. now it displays all post content at homepage, I created a short_desc Custom Field. and I call it from code with;
<?php //get_post_meta($post->ID, 'short_desc', true); ?>
it is fine. but i need to display this short desc at home page listing, and the main content at details page. how can do that?
I appreciate helps!!
It sounds like what you are trying to do is show a custom field that you have set on a post on the index page (which lists all the posts).
To do that you'll need to modify index.php by adding your snippet where you would like to have the short description.
<?php echo get_post_meta($post->ID, 'short_desc', true); ?>
You need to use echo to display the results from the get_post_meta function.
Depending on how your posts are setup you can also use the More button when you write your posts. This will cut off your post at a certain point that you decide and only show that short part on the index and archive pages.
Another option would be to use
<?php the_excerpt(); ?>
Which shows the first 55 words (this can be adjusted though) of the post.
Hope that helps,
Paul

Resources