Placement of Code in Plugin for hooking `save_post`

I’m not sure if if( !current_user_can( ‘edit_post’, $post_id ) ) return; really works. Maybe the current user isn’t set up there and you’ll have to work around it by passing the user ID in a hidden field, then retrieving it using $user = get_user_by( ‘id’, esc_attr( $_POST[‘user_id’] ) ); wp_set_current_user( $user->user_id ); if ( ! … Read more

javaScript in section of WP API

Uncaught TypeError: Property ‘$’ of object [object Object] is not a function Are you positive you’re accessing the jQuery object correctly? You should look into how WordPress uses noConflict mode. In the noConflict() mode, the global $ shortcut for jQuery is not available, but you can still use: jQuery(document).ready(function(){ jQuery(#somefunction) … }); As a footnote, … Read more

How to show in search results posts with a particular tag in a particular category?

Given the way categories & tags are setup in WordPress this would not work from a logical standpoint. The issue here is that tags have no way to be connected directly to a category, they are mutually exclusive from each other. The subcategories would work because a subcategory is directly related to is parent category … Read more

Recent post display using shortcode

You have missed the quotes in the_permalink(). Use following code function my_recent_posts_shortcode($atts){ $q = new WP_Query( array( ‘orderby’ => ‘date’, ‘posts_per_page’ => ‘4’) ); $list =””; while($q->have_posts()) : $q->the_post(); echo ‘<div class=”item”>’; $title=get_the_title(); if ( has_post_thumbnail() ) { $list .= ‘<a class=”single-image link-icon” href=”‘. get_permalink().'”>’.the_post_thumbnail(array(300,200),array(‘alt’ =>$title)).'</a>’; } $list .= ‘<h6 class=”title”><a href=”.the_permalink().”><span>”‘.the_title().'”</span></a></h6>’; echo ‘<div class=”entry-body”>’; … Read more

add a function to submit options.php

You could just do a check for settings updated, and call a function. At the top of the page that renders the settings form: if ( isset( $_GET[‘settings-updated’] ) && $_GET[‘settings_updated’] == true ) { your_custom_function(); } Then define the custom function in your functions.php or add it to a class.