Create a category list page

To display a list of categories on your page by just putting something into the content area, you need a shortcode. You can create a shortcode by using add_shortcode. This defines the tag and the function to call when that shortcode is used. Here’s a basic example that creates a shortcode [my_cat_list]: /** * This … Read more

Add a URL prefix to permalinks of one category of posts only

Suppose articles is slug of the category. 1. Add a custom rewrite rule: add_action(‘init’, function() { add_rewrite_rule(‘^articles/([^/]+)/?$’, ‘index.php?name=$matches[1]’, ‘top’); }, 10, 0); 2. Filter the post link: add_filter(‘post_link’, function($post_link, $post, $leave_name = false, $sample = false) { if ( has_category(‘articles’, $post) ) { $post_link = str_replace(“https://wordpress.stackexchange.com/” . $post->post_name, ‘/articles/’ . $post->post_name, $post_link); } return $post_link; … Read more

Hook when category is added to post

You may want to try: do_action(‘set_object_terms’, $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); You can find it under this Docs and the action is located at wp-includes/taxonomy.php add_action(‘set_object_terms’,’wpse5123_set_object_terms’,10,4); function wpse5123_set_object_terms($object_id, $terms, $tt_ids, $taxonomy){ if($taxonomy == ‘category’){ echo ‘<pre>’; print_r($terms); echo ‘</pre>’; exit; } } The code above isn’t tested but I think you get the point.

What is a good robots.txt?

FWIW, trackback URLs issue redirects and have no content, so they won’t get indexed. And at the risk of not answering the question, RE your points 2 and 3: http://googlewebmastercentral.blogspot.com/2008/09/demystifying-duplicate-content-penalty.html Put otherwise, I think you’re wasting your time worrying about dup content, and your robots.txt should be limited to: User-agent: * Disallow: /cgi-bin Disallow: /wp-admin … Read more

get_terms vs. get_categories: does it matter?

As you dive into WordPress, you’ll find that WordPress has a lot of wrapper functions. For instance, there’s add_theme_page that’s just a wrapper of add_submenu_page. That’s certainly not the only example (add_submenu_page itself has a bunch of wrappers, in fact). If you look at the source for get_categories(), you’ll see that it too is a … Read more

Best Way to Redirect Category to Page and Hide Category

I don’t know for some reason, the add_filter caused error. I used the following one: function my_page_template_redirect() { if ( is_category( ‘news-articles’ ) ) { $url = site_url( ‘/news’ ); wp_safe_redirect( $url, 301 ); exit(); } } add_action( ‘template_redirect’, ‘my_page_template_redirect’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)