Lightbox on wordpress post page

Before anything… to get a good answer, you need to provide a good question. Code examples would help a lot. You can use jQuery to accomplish what you need. Suppose your checkboxes are in a list. You can assign an ID to the list UL. You can use jQuery to run through every element in … Read more

How to exclude the word “class” from being matched in search?

You might try to use the posts_search filter as elegantly suggested by @Kaiser in the first link you provided. Here is one idea: function filter_search($sql){ global $wpdb; if( strpos(get_query_var(“s”),”lass”) !== false AND strpos(get_query_var(“s”),”class”) === false ){ $sql .= ” AND {$wpdb->posts}.post_title NOT LIKE ‘%class%'”; $sql .= ” AND {$wpdb->posts}.post_content NOT LIKE ‘%class%'”; } return $sql; … Read more

Display message depending on capability outside loop

Use global $authordata: Testing for roles: global $authordata; if ( in_array( ‘administrator’, $authordata->roles ) ) { echo ‘Hello Admin!’; } elseif ( in_array( ‘editor’, $authordata->roles ) ) { // echo something else } Or testing for capabilities: if ( ! empty ( $authordata->allcaps[‘manage_options’] ) ) { echo ‘The author can manage options’; } elseif ( … Read more

load more posts by category

You will need to load the next 10 posts with an AJAX request and keep the current offset stored in the DOM. Attach an ID to the <span> element which is your button, in my example I have used #load_posts. Then using jQuery, you can easily setup the click event for the button to fire … Read more

How to display only one category in a custom post type?

Something like this should work but you haven’t stated where you want to display the CPT pages for games. function display_games_archive( $query ) { if ( !is_admin() || $query->is_main_query() && is_post_type_archive( ‘portcat’ ) ) { $query->set( ‘category__in’, ‘games’ ); return; } } add_action( ‘pre_get_posts’, ‘display_games_archive’, 1 );

alternative to wp_link_pages() that only shows link to last page

Crib a bit of code from wp-includes/query.php and bit from wp-includes/post-template.php, add a little, mix and stir, and… function url_to_last_page() { global $post; $content = str_replace(“\n<!–nextpage–>\n”, ‘<!–nextpage–>’, $post->post_content); $content = str_replace(“\n<!–nextpage–>”, ‘<!–nextpage–>’, $content); $content = str_replace(“<!–nextpage–>\n”, ‘<!–nextpage–>’, $content); $pages = explode(‘<!–nextpage–>’, $content); $numpages = count($pages); $ret = _wp_link_page($numpages); $ret .= $numpages; $ret .= ‘</a>’; return … Read more

How to display WP Query filters?

There’s a global variable called $wp_filter (you can see examples of it all through the source of /wp-includes/plugin.php. This probably isn’t the WordPress Way to do it, but you could try something like this: global $wp_filter; var_dump( $wp_filter ); …but note the caveat on http://codex.wordpress.org/Global_Variables — “Accessing other globals besides the ones listed below is … Read more

write a post on user registration

Use the ‘user_register’ WordPress action to add the post function. Use wp_insert_post() to add the post. add_action( ‘user_register’, ‘wpse_99270_new_user_post’ ); /** * Add a new post when user registers. */ function wpse_99270_new_user_post( $user_id ) { // Get user data. $user_data = get_userdata( $user_id ); // Add new post here. wp_insert_post( array( ‘post_title’ => wp_strip_all_tags( sprintf( … Read more