Custom classes for attachments

Just add the following code in functions.php file of your theme which will add your custom added classes to images when you will insert it into post editor. function add_image_class($html, $id, $caption, $title, $align, $url, $size, $alt=”” ){ $classes = get_post_meta( $id, ‘classes’, true ); if ( preg_match(‘/<img.*? class=”.*?”>/’, $html) ) { $html = preg_replace(‘/(<img.*? … Read more

Change event firing in wordpress

Using transistion_post_status I’m able to retrieve post meta. add_action( ‘transition_post_status’, ‘post_published’, 10, 3 ); function post_published( $new_status, $old_status, $post ) { if ( $old_status != ‘publish’ && $new_status == ‘publish’ ) { $meta = get_post_meta($post->ID); echo ‘<pre>’; var_dump($meta); echo ‘</pre>’; die(); } }

How to keep sharing stats after creating 301 redirects?

Got it. I was already using the Advanced Custom Fields plugin so I just created a custom field called “old_url” with that. Then I created a function: function sharingurl () { if(get_field(‘old_url’) == “”) { echo untrailingslashit(get_permalink()); } else { echo get_field(‘old_url’); } } Then I just included <?php sharingurl(); ?> in the data-href and … Read more

Can i categorise my meta box?

The code you posted in your question is very very very incomplete, anyway I will try to give you an answer. You can define as many meta box as you need and put inside each meta box the fields you want. For example: add_action( ‘add_meta_boxes’, ‘my_meta_boxes’ ); function my_meta_boxes(){ //We define the two metaboxes I … Read more

Custom Fields – How can I remove the publish option for certain users

You can do something like this : function wpse_113057_hide_publish_buttons(){ $cpt=”your_post_type”;// can be post global $post; if($post->post_type == $cpt && current_user_can(‘members’) ){ echo ‘ <style type=”text/css”> .misc-pub-section, #delete-action { display:none; } </style> ‘; } } add_action(‘admin_head-post.php’, ‘wpse_113057_hide_publish_buttons’); add_action(‘admin_head-post-new.php’, ‘wpse_113057_hide_publish_buttons’); I did not find a hook to do this with some PHP. Hope this helps.

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