How to get url of a post from admin panel

You can get the ID of the post you’re editing like this: //currently edited post id $cep_id = $_GET[‘post’]; //permalink get_permalink( $cep_id ); This is and can only work if your editing an existing/saved post. It won’t and can’t work on »Add New«-Pages, because the post you’re going to add isn’t saved to the database … Read more

How to set global variable in functions.php

You can turn your snippet into a function that returns the post thumbnail URL of a post: function wpse81577_get_small_thumb_url( $post_id ) { $thumbSmall = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), ‘small’ ); return $thumbSmall[‘0’]; } Usage, supplying the ID of a post: <?php echo wpse81577_get_small_thumb_url( 59 ); ?>

How to create a permalink structure for posts in a specific category

I am not sure if this is the best solution or not, but it works: function movie_review_permalink( $url, $post, $leavename ) { $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->slug == “test” ) { //change ‘test’ to your category slug $date=date_create($post->post_date); $my_date = date_format($date,”dmY”); $url= trailingslashit( home_url(“https://wordpress.stackexchange.com/”. $category[0]->slug .”https://wordpress.stackexchange.com/”. $post->post_name .’-‘. $my_date .”https://wordpress.stackexchange.com/” ) ); … Read more

How to make WordPress use protocol indepentent upload files?

You can define a function to remove the protocol and hook it to the attachment URL: function wpse_79958_remove_protocol_from_attachment($url) { $url = str_replace(array(‘http:’, ‘https:’), ”, $url); return $url; } add_filter( ‘attachment_link’, ‘wpse_79958_remove_protocol_from_attachment’ ); Also consider to use relative URLs for attachments by using WordPress builtin function wp_make_link_relative: add_filter( ‘attachment_link’, ‘wp_make_link_relative’ ); Place this code to your … Read more

Using URL parameters, list posts from category and custom taxonomy

In general circumstances, using URL parameters, you can list posts that belong to a specific category AND a custom taxonomy, like this: http://example.com/category/cars/?edition=usa Where, category is the Category base you are using for categories on your site (WordPress Dashboard > Settings > Permalinks > Category base); edition is the custom taxonomy’s base/slug; and usa is … Read more

Pretty Permalinks

You should add your own custom query variable first: function add_search_store_query_var($vars) { $vars[] = ‘search_store’; return $vars; } add_filter( ‘query_vars’, ‘add_search_store_query_var’); And then add rewrite rule: function add_search_store_rewrite_rule() { add_rewrite_rule(‘stores/([^/]+)$’, ‘index.php?page_id=<YOUR SEARCH PAGE ID>&search_store=$matches[1]’, ‘top’); } add_action(‘init’, ‘add_search_store_rewrite_rule’); You can then use get_query_var(‘search_store’); to get search term. Just remember to flush rewrite rules, before you … Read more

Bulk Delete Users Error uri too large

I would shy away from trying to do this is SQL. It is possible but probably not necessary and is more prone to error that using WordPress Core functions. You could use get_users() or WP_User_Query to retrieve your users but given that you only want to keep two users and you only need the ID … Read more

Run WordPress frontend and backend in different domains

There’s no need to do it the way you mean. There are ways to host multiple SSL websites on a single domain both with Apache and Nginx, and it’s much easier to implement than your idea. Check out these tutorials: https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-ssl-certificates-on-one-ip-with-apache-on-ubuntu-12-04 https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-ssl-certificates-on-one-ip-with-nginx-on-ubuntu-12-04

URL for custom post type

….if you are planning to have many entries (say – over 100), you will run into memory issue Any hierarchical post type (even the build-in post type page) have this issue where a large amount of posts created have a huge impact on performance. This issue is experienced in the back end, and not in … Read more