Want to filter only parent post in admin area

In addition to my previous answer add following code. It should work fine add_filter( ‘views_edit-books’, ‘add_filter_link’ ); function add_filter_link( array $views ) { $url = add_query_arg( array(‘bfilter’=>’parents’,’post_parent’=>0,’post_type’=>’books’), ‘edit.php’ ); $views[ ‘post_parent’ ] = sprintf( ‘<a href=”%1$s”%2$s>%3$s</a>’, esc_url( $url ), ( is_filter_active() ) ? ‘ class=”current” aria-current=”page”‘ : ”, ‘Post Parents’ ); return $views; } function … Read more

WPDB->insert with special characters

If the same code works with add_option() and not with $wpdb->insert() in a custom table, it is probably because the collation of the custom table does not support the characters of the inserted data. It shoulud work if you set the collation of your table to UTF-8, utf8_general_ci at minimum (to allow support for emojis, … Read more

$wpdb prepared with search term

After a million tries I finally found it… $result = $wpdb->get_results($wpdb->prepare(“SELECT id, geslacht, voornaam, familienaam, email, tel, afile, app_datum FROM sollicitatie_form WHERE voornaam = %s”, $zoekvn)); I guess when you found the solution yourself you’re less likely to forget it 🙂

Get number of comments after modifying comment query

Refrain from editing core files WordPress was developed with extensibility in mind, and provides many ways to change the appearance and functionality of an installation without altering the WordPress software itself (mostly using Hooks in conjunction with Plugins and Themes). The software is comprised of it’s “core files”, which are generally everything outside of the … Read more

How do I create a single.php for a specific category?

I think this does what you want: function ag_templates( $template=”” ){ global $post; $meta = get_post_meta( $post->ID, ‘_category_permalink’, true ); if( 53 == $meta ){ $template = locate_template( array( “single-category-53.php”, $template ), false ); } return $template; } add_filter( ‘single_template’, ‘ag_templates’ );

Speed optimization of $wpdb->get_results

Your query is incorrect in the first place because you’re not doing the join correctly. What you’re actually selecting with that query is just all the postmeta’s autor fields, without regards to whether the post is published or not. Here’s the corrected query. SELECT meta_value AS autor FROM wp_posts JOIN wp_postmeta ON (wp_postmeta.post_id = wp_posts.ID) … Read more

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