Create additional short URL with custom field and 301 redirect

The first step is the rewrite rule. I’ve also added a rewrite tag so the custom query var will be parsed. You can also use the query_vars filter for this instead. add_action( ‘init’, ‘tipp_rewrite_rule’ ); function tipp_rewrite_rule() { add_rewrite_tag( ‘%trick_nummer%’, ‘([a-zA-Z0-9]+)’ ); add_rewrite_rule( ‘^tipp([a-zA-Z0-9]+)?’, ‘index.php?trick_nummer=$matches[1]’, ‘top’ ); } The second step is to intercept these … Read more

How to save values of a custom input field on the Network > Site Info screen

The problem was a redirect in site-info.php. After that the $_POST variable was empty in the code inserting in the admin_footer. I just need to use a further hook ‘admin_init’ and save the value here. add_action(‘admin_init’, ‘pg_save_custom_site_options’); function pg_save_custom_site_options(){ global $pagenow; if( ‘site-info.php’ == $pagenow && isset($_REQUEST[‘action’]) && ‘update-site’ == $_REQUEST[‘action’] ) { // Use … Read more

Adding existing user custom field value to a woocommerce product [closed]

You can do this with an action when a new product is inserted (and not when updated). As you did not specify the meta key this field is stored under the user as, OR the meta key of where you want it stored on the product: add_action( ‘wp_insert_post’, ‘smyles_insert_user_product_data’, 10, 3 ); function smyles_insert_user_product_data( $post_ID, … Read more

How to get a meta value from all post

get_col() function returns only one column as array. To get two column result we can use get_results(), Which will return an array of objects Which further can be converted into required structure using foreach loop. Example – function get_meta_values( $key = ”, $type=”post”, $status=”publish” ) { global $wpdb; if( empty( $key ) ) return; $r … Read more

Guest Author – How can I use custom fields to create guest author link?

Remove the filters and the function used in the tutorial you linked and replace them with this code: add_filter( ‘get_the_author_user_url’, ‘guest_author_url’ ); add_filter( ‘the_author’, ‘guest_author_link’ ); add_filter( ‘get_the_author_display_name’, ‘guest_author_name’ ); function guest_author_url($url) { global $post; $guest_url = get_post_meta( $post->ID, ‘guest-url’, true ); if ( filter_var($guest_url, FILTER_VALIDATE_URL) ) { return $guest_url; } elseif ( get_post_meta( $post->ID, … Read more

Custom Meta Field not Working with qTranslate [closed]

Less complicated is to use the plugin’s Quicktags and use the Gettext functions to print the content in the site. [:en]English[:pt]Português Quicktags docs Another option is to do just like qTranslate interface does with the post titles: Create one custom field for each language in your meta box: qTrans documentation is not consolidated, so analyzing … Read more

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