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 auto strip hyperlinks & images in wordpress post

Here is one idea to strip link- and image tags from the post content (before you save it) by using the edit_post_content filter and the wp_kses function: add_filter( ‘edit_post_content’, ‘my_edit_post_content’, 10, 1 ); function my_edit_post_content( $content ) { if (!current_user_can(‘manage_options’)) { // only strip for non-admins global $allowedposttags; $mytags = $allowedposttags; unset($mytags[‘a’]); // don’t allow … 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

Enable comments for post when comments meta box removed

Filter the ‘comments_open’ check. It happens inside of the function with the same name, and that function is called in a theme usually like this: comments_open() and comment_form( array ( ‘comment_notes_after’ => ” ) ); This is how the filter works: add_filter( ‘comments_open’, ‘wpse_98775_comment_check’, 10, 2 ); function wpse_98775_comment_check( $open, $post_id ) { if ( … Read more