Show chart in post using data passed as custom field

Welcome to WPSE. The first thing to note is that you may want to put any custom code you write for this functionality into a custom plugin. This way the functionality is theme independent and available to you even, if you someday change the theme you’re using. The modern way would be to create a … Read more

Show author post count in sidebar – Variable

To get the number of posts published by a user i found the solution was to call count_user_posts(), passing in the appropriate user id. <?php echo ‘Posts made: ‘ . count_user_posts( get_the_author_meta(‘ID’) ); ?> In translation ready form. <?php printf( ‘Posts made: %d’, count_user_posts( get_the_author_meta(‘ID’) ) ); ?> Storage in a variable. <?php $user_post_count = … Read more

Adding a Nav menu to post admin

To see how such a list can be created look at the code in wp-admin/includes/nav-menu.php. Unfortunately, it is hard coded there, so you have to re-create the code. First, let’s create two menus: We can get these menus in PHP with wp_get_nav_menus() (a wrapper for get_terms()): $menus = wp_get_nav_menus(); print ‘<pre>’ . htmlspecialchars( print_r( $menus, … Read more

How to remove_filter that filters iframes in posts? [duplicate]

This filter does not. This feature is disabled in the visual editor TinyMCE. function wpse49619_change_mce_options($initArray) { $ext=”iframe[align|longdesc|name|width|height|frameborder|scrolling|marginheight|marginwidth|src]”; if ( isset( $initArray[‘extended_valid_elements’] ) ) { $initArray[‘extended_valid_elements’] .= ‘,’ . $ext; } else { $initArray[‘extended_valid_elements’] = $ext; } // maybe; set tiny paramter verify_html //$initArray[‘verify_html’] = false; return $initArray; } add_filter(‘tiny_mce_before_init’, ‘wpse49619_change_mce_options’); Also you can use examples … Read more

This AJAX Code Doesn’t Work – Looking for elegant solution

Working Code Based On My Previous Answer Without using nonce.. but you can check the previous answer on how you can implement a nonce check. And the code is based on your code. misha_my_load_more_scripts() in functions.php function misha_my_load_more_scripts() { wp_register_script( ‘my_loadmore’, get_stylesheet_directory_uri() . ‘/js/myloadmore.js’, array( ‘jquery’ ), ”, true ); wp_enqueue_script( ‘my_loadmore’ ); } add_action( … Read more

404 error after publishing a post

I just ran into something similar to this. It had to do with refreshing permalinks. If you go to Settings -> Permalink and just click save see if it fixes your problem. It did for me. In the end I added the following to my functions.php file which updated the permalinks for me. I was … Read more

Exclude category on blog list page

From a plugin or your theme’s functions.php file: function wpse106861_mod_query( $query ) { /* are we on the blog page ? */ if ( $query->is_home() && $query->is_main_query() ) { /* get ID of news category */ $news_id = get_cat_ID( ‘news’ ); /* exclude posts in new from query */ $query->set( ‘category__not_in’ => array( $news_id ) … Read more

Add custom field to all posts in specific category

You can use WordPress functions to do this and just run it once, a fast example would be. function wpse_85236_add_photo_field(){ global $post; $photoquery = new WP_Query(‘posts_per_page=-1’); while ( $photoquery->have_posts() ) : $photoquery->the_post(); if ( in_category( ‘photography’ )) { add_post_meta($post->ID, ‘category’, ‘photography’, true); } endwhile; } add_action( ‘init’, ‘wpse_85236_add_photo_field’ ); Remember to remove the function after … Read more

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