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

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