Prevent duplicate posts in wp_insert_post using custom fields

To save the link in the post meta you can use update_post_meta like this for example: $url = “http://sample.com/entertainment/default.aspx?tabid=2305&conid=102950” $my_post = array( ‘post_title’ => “$title”, ‘post_content’ => “$content”, ‘post_status’ => ‘draft’, ‘post_author’ => 1, ‘post_category’ => array(1), ); $post_id = wp_insert_post( $my_post ); update_post_meta($post_id,’source_link’,$url); and to prevent the insertion add a simple conditional check: $args … Read more

How to add users roles dropdown in registration in wordpress

https://codex.wordpress.org/Customizing_the_Registration_Form https://codex.wordpress.org/Function_Reference/wp_update_user Instead of update_user_meta function in user_register hook use wp_update_user Following is the working example: //1. Add a new form element… add_action( ‘register_form’, ‘myplugin_register_form’ ); function myplugin_register_form() { global $wp_roles; echo ‘<select name=”role” class=”input”>’; foreach ( $wp_roles->roles as $key=>$value ) { // Exclude default roles such as administrator etc. Add your own if ( … Read more

Showing current taxonomy terms

try this: <?php get_header(); ?> <? // get the current term $term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); <div class=”container” role=”main”> <h1 class=”entry-title”><?php echo $term->name; ?></h1> <div class=”entry-content ref”> <?php $loop = new WP_Query( array( ‘post_type’ => ‘references’ , ‘genre’ => $term->slug) ); ?> <?php while ( $loop->have_posts() ) : $loop->the_post(); … Read more

TinyMCE style_select – Append Classes

EDIT The quick and easy method is just a simple setting: style_formats_merge… function myformatTinyMCE($in) { $style_formats = array( array( ‘title’ => ‘Classes’, ‘items’ => array( array( ‘title’ => ‘Blue Color’, ‘selector’ => ‘p,strong,u,em,ol,ul’, ‘classes’ => ‘blueColor’ ) ) ) ); $in[‘style_formats_merge’] = true; $in[‘style_formats’] = json_encode( $style_formats ); return $in; } add_filter(‘tiny_mce_before_init’, ‘myformatTinyMCE’ ); Everything … Read more

adding a custom css class to post

Note – I recommend using the hook suggested by @Chip Bennett in another answer Here’s the modified version of that filter – function wpse_filter_post_class( $classes ) { $my_post_class = get_post_meta($post->ID, “your_meta_name”); if( $my_post_class != ” ) $classes[] = $my_post_class; return $classes; } add_filter( ‘post_class’, ‘wpse_filter_post_class’ ); You can setup a Custom fileds for that – … Read more

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