Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Category Archive

Here’s two different solutions (editing the specifics for your use case): Doing a Redirect: 1.) At the top of your /wp-config.php file add the following: if ( is_yoursite_blogger_domain( $_SERVER[‘SERVER_NAME’] ) ) { $domain = str_replace( ‘www.’, ”, $_SERVER[‘SERVER_NAME’] ); define( ‘WP_SITEURL’, ‘http://’ . $domain ); define( ‘WP_HOME’, ‘http://’ . $domain ); } else if ( … Read more

How to add the category ID to admin page

The hooks for taxonomies are: “manage_edit-${taxonomy}_columns” for the header “manage_edit-${taxonomy}_sortable_columns” to make columns sortable “manage_${taxonomy}_custom_column” for the cell content To catch all taxonomies write: foreach ( get_taxonomies() as $taxonomy ) { add_action( “manage_edit-${taxonomy}_columns”, ‘t5_add_col’ ); add_filter( “manage_edit-${taxonomy}_sortable_columns”, ‘t5_add_col’ ); add_filter( “manage_${taxonomy}_custom_column”, ‘t5_show_id’, 10, 3 ); } add_action( ‘admin_print_styles-edit-tags.php’, ‘t5_tax_id_style’ ); function t5_add_col( $columns ) { … Read more

Adding Colorpicker Field To Category

This has been updated for WordPress 4+ with the introduction of Term Meta. The code is heavily commented. :: My Functions – functions.php :: The below function is to display the colorpicker on the “Add New Category” screen: /** * Add new colorpicker field to “Add new Category” screen * – https://developer.wordpress.org/reference/hooks/taxonomy_add_form_fields/ * * @param … Read more

get_terms name__like list categories according to letter

Use the terms_clauses filter, which passes all the various components of the query (fields, join, where, orderby, order & limits), and implement your own “search” argument: function wpse_178511_get_terms_fields( $clauses, $taxonomies, $args ) { if ( ! empty( $args[‘surname’] ) ) { global $wpdb; $surname_like = $wpdb->esc_like( $args[‘surname’] ); if ( ! isset( $clauses[‘where’] ) ) … Read more

How to filter categories by custom field?

You should be able to use the meta_query attribute that uses WP_Meta_Query behind the scenes: $child_categories = get_categories( array( ‘parent’ => $cat_id, ‘orderby’ => ‘id’, ‘order’ => ‘DESC’, ‘hide_empty’ => ‘0’, ‘meta_query’ => array( array( ‘key’ => ‘mykey’, // Adjust to your needs! ‘value’ => ‘myvalue’, // Adjust to your needs! ‘compare’ => ‘=’, // … Read more

Why is per_page not working with categories in WP API?

Pretty much all the URLs you are using are invalid in some way: http://foobar.com/wp-json/wp/v2/posts/categories_name=hello categories_name is not a valid argument for listing posts, and even if it was you are missing the ? part of the query string. http://foobar.com/wp-json/wp/v2/posts/categories_name=hello?per_page=‌​1 This one is also missing the ?. Query parameters on a URL, which the API uses … Read more

Rewrite URL with category and tag combined using WP_Rewrite

These should work for you: function myplugin_rewrite_tag_rule() { add_rewrite_rule( ‘category/(.+?)/tag/([^/]+)/?$’, ‘index.php?category_name=$matches[1]&tag=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘category/(.+?)/tag/([^/]+)/page/?([0-9]{1,})/?$’, ‘index.php?category_name=$matches[1]&tag=$matches[2]&paged=$matches[3]’, ‘top’ ); } add_action(‘init’, ‘myplugin_rewrite_tag_rule’, 10, 0); The second rule is to support pagination so you can have: https://example.com/category/healthy-living/relationships/tag/flock as well as: https://example.com/category/healthy-living/relationships/tag/flock/page/2/ Note that you don’t need to add a rewrite tag, as it’s already added by core.

Exclude categories from search query

You can use pre_get_posts action to exclude categories from search query. function wcs_exclude_category_search( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_search ) { $query->set( ‘cat’, ‘-22, -21’ ); } } add_action( ‘pre_get_posts’, ‘wcs_exclude_category_search’, 1 ); You should paste this code in your theme’s functions.php file.

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