Rewrite only if no other matching page is found

It turns out it was because the default category archive pages do not require the URL to start with /category. WordPress already matches the path /{category-slug} for the default category taxonomy archive. I fixed it by changing the default category archive rewrite to start with /category. function move_category_rule($rules) { if(array_key_exists(‘(.+?)/?$’, $rules)) { $val = $rules[‘(.+?)/?$’]; … Read more

How to hide protected posts from archive?

There are 2 answers depending on where you want to do this. One has good news, the other has bad news Anywhere That Uses Post Queries Modifying the SQL is rarely necessary here and usually a sign that something was overlooked. In this case, WP_Query already provides a simple parameter to do this named has_password. … Read more

Customize URL for specific tags archive

@ederico-dondi On your tag listing page, WordPress is getting the content of the page from your url querystring. In your case, there is “tag” in your url so it will understand that you are on tag page. If you will remove tag then it will not show data of tag. for example. the below code … Read more

Custom Post Type Archive Page showing as 404

While registering custom_post_type use this parameters too. ‘publicly_queryable’ => true, Then it should be look like this. function wporg_custom_post_type() { register_post_type(‘proctor-work’, array( ‘labels’ => array( ‘name’ => __( ‘Works’, ‘textdomain’ ), ‘singular_name’ => __( ‘Work’, ‘textdomain’ ), ), ‘public’ => true, ‘has_archive’ => true, ‘rewrite’ => array( ‘slug’ => ‘proctor-work’ ), // my custom slug … Read more

How do I make an array to get the category name, dynamically, in an archive template?

You can try something like: if ( is_category() ) { $cat = get_category( get_query_var( ‘cat’ ) ); // $cat_id = $cat->cat_ID; $cat_name = $cat->name; // $cat_slug = $cat->slug; $args = array( ‘category_name’ => $cat_name, ‘post_type’ => ‘post’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘DESC’, ); … The function you are looking for is get_category, as well … Read more

Display WordPress archive template page in 3 columns and not 1 column [closed]

Without knowing the structure, class names, ids etc. it would be impossible to give you an answer that would help. But lets say that the structure is ul>li*6 <ul> <li>…</li> <li>…</li> <li>…</li> <li>…</li> <li>…</li> <li>…</li> </ul> The must basic of css that would create such a design would be ul { display: grid; grid-template-columns: repeat(3, … Read more

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