Rewrite rule page url with category

Just of the top of my head, something along this way might work: function wpse178647_rewrite() { add_rewrite_rule( ‘^([^/]+)/([^/]+)/?$’, ” ‘index.php?category_name=$matches[1]&pagename=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘wpse178647_rewrite’ ); Completely and utterly untested.

What’s the URL for a category archive?

There is no date-based archive for a category. The /category/[slug]/ pages are already “archives”, in that they display old posts over different pages. The different pages can be accessed by adding page/2/, page/3/, … to the URL. The template tags to add these links are next_posts_link() and previous_posts_link(). If you want to add a date-based … Read more

How can I make post fields required in WordPress?

Fairly simple using jQuery and global $typenow ex: add_action(‘admin_print_scripts-post.php’, ‘my_publish_admin_hook’); add_action(‘admin_print_scripts-post-new.php’, ‘my_publish_admin_hook’); function my_publish_admin_hook(){ global $typenow; if (in_array($typenow, array(‘post’,’page’,’mm_photo ‘))){ ?> <script language=”javascript” type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#post’).submit(function() { if (jQuery(“#set-post-thumbnail”).find(‘img’).size() > 0) { jQuery(‘#ajax-loading’).hide(); jQuery(‘#publish’).removeClass(‘button-primary-disabled’); return true; }else{ alert(“please set a featured image!!!”); jQuery(‘#ajax-loading’).hide(); jQuery(‘#publish’).removeClass(‘button-primary-disabled’); return false; } return false; }); }); </script> <?php } … Read more

Get top parent category

get_ancestors() returns an array containing the parents of any given object. This example has two categories. The parent with the id of 447 and the child with a id of 448 and returns the a category hierarchy (with IDs): get_ancestors( 448, ‘category’ ); returns: Array ( [0] => 447 ) get_ancestors Codex Page

How to display only 3 main categories, separated by commas, since they are marked in the post?

It should be enough using a single <span> for all categories and add some logic.: <span><?php $categories = [‘horses’,’dogs’,’birds’]; $string = “”; foreach ($categories as $category){ //iterate over the categories to check if(has_category($category)) $string .= $category.”, “; //if in_category add to the output } $string = trim($string); //remove extra space from end $string = rtrim($string, … Read more

Where/how are categories stored?

There is extensive documentation on the database structure of WordPress in the Codex. Its pretty simple but still you probably do not want to mess with the data directly. As you mentioned CLI I’d recommend WP-CLI which offers some commands you need. A quick example from the docs to change the name of the term … Read more

How do I use the same post slug for different Categories?

Using Parent-Child Page (Recommended) If you don’t have to have categories & posts, then this can be easily achieved using parent-child pages (not posts). For example, say you have three pages like: www.example.com/category-one/ www.example.com/category-two/ www.example.com/category-three/ Now you can have child pages for the above pages with slug email, e.g. www.example.com/category-one/email www.example.com/category-two/email www.example.com/category-three/email This is possible … Read more

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