How to get home page ID?
$pageID = get_option(‘page_on_front’); should get you the Page ID of the page set at ‘Front Page’ in WordPress options.
$pageID = get_option(‘page_on_front’); should get you the Page ID of the page set at ‘Front Page’ in WordPress options.
Giving a blank array to ‘supports’ in the declaration of the post type should get rid of the editor and the title, along with every other default box in the edit post page. $supports = array (”); $args = array( ‘label’ => ‘people’, ‘supports’ => $supports, ‘hierarchical’ => false, ‘public’ => true, ‘rewrite’ => true … Read more
Set orderby to post__in. This preserves post ID order given in the post__in array (available with Version 3.5). $args = array ( ‘posts_per_page’ => -1, ‘post__in’ => $ids, ‘orderby’ => ‘post__in’ );
Codex has example snippet on how to use post_limits filter to override amount set in admin for feed. if (isset ($query->query_vars[‘feed’]) and ($query->query_vars[‘feed’] == ‘ics’)) add_filter(‘post_limits’,’__return_empty_string’); http://codex.wordpress.org/Function_Reference/query_posts#Usage_Tips
This the post__not_in arg should work dandy for you: $args = array( ‘numberposts’ => 5, ‘offset’ => 0, ‘category’ => 7, ‘post__not_in’ => array( $post->ID ) ); $myposts2 = get_posts($args);
Add this as well: add_action(‘wp_ajax_nopriv_my_action’, ‘my_action_callback’);. Notice the nopriv. It will solve your problem!
There’s nothing built in to return the bit you want but it should be as easy as using the home_url() function and removing it’s output from the full url eg: function get_relative_permalink( $url ) { return str_replace( home_url(), “”, $url ); }
You could check to see if the ‘WooCommerce’ class exists, then run the code that requires WooCommerce. <?php if ( class_exists( ‘WooCommerce’ ) ) { // code that requires WooCommerce } else { // you don’t appear to have WooCommerce activated } ?>
Fastforward to WordPress 4.4 – it will support the role__in attribute! It looks like WordPress 4.4 is our lucky version number, because it will support both the role__in and role__not_in attributes of the WP_User_Query class. So to include the subscriber, contributor and author roles, we can simply use: $users = get_users( [ ‘role__in’ => [ … Read more
I agree with david-binda – great question! I’ve run in to this problem on a number of occasions and come up with a solution that works pretty well. While I do like the idea of adding a shortcode to insert the image with classes as suggested by pavlos-bizimis I don’t think it really solves the … Read more