OOP Plugin Development. Including external object

The root of your problem is not object oriented programming, but a fundamental misunderstanding about how PHP handles requests. If this were a Java or a Node application for example, you would start the application on the server, and it would recieve requests, and respond. It’s a continuous active program. As a result, you can … Read more

Targeting single page with JS

Here, the code operates on anything that matches the #searchButton element: jQuery(“#searchButton”) If there is a searchButton on other pages, it will match it, soo you need to be more specific. For example, on the homepage, the <body> tag will have the home class, here is my sites homepage body tag: <body class=”home blog logged-in … Read more

Bulk Image upload and one image for each post?

Maybe this is helpful: http://wordpress.org/extend/plugins/add-from-server/ See also: https://duckduckgo.com/?q=wordpress+bulk+upload+images google for wordpress bulk image upload And there is also: https://wordpress.stackexchange.com/ stackoverflow for wordpress related questions.

How do I make wordpress comment fields required?

First of all, I highly recommend using the comment_form() function. It’s all of the above code in one line (more if you need to tweak parts of the code). You can designate name and email as required in the settings section of your admin area:

wp_delete_auto_drafts() deletes links in menus

This is what normal query run by wp_get_associated_nav_menu_items() looks like: SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.id = wp_postmeta.post_id ) WHERE 1 = 1 AND wp_posts.post_type=”nav_menu_item” AND (( wp_posts.post_status <> ‘trash’ AND wp_posts.post_status <> ‘auto-draft’ )) AND (( wp_postmeta.meta_key = ‘_menu_item_object_id’ AND Cast(wp_postmeta.meta_value AS CHAR) = ‘3111’ )) GROUP BY wp_posts.id ORDER … Read more

If in parent category

The is_category Conditional Tag checks if a Category archive page is being displayed – hence it is expected to return false on single post pages, whether the post in question is in said category or not. To check for the latter condition, make use of has_category. If you want the content to show up on … Read more

if has theme mod

try this code: if( get_theme_mod(‘your_setting_name’) ){ //your code }else{ //your code } Note: get_theme_mod() return false if no value exist for your setting

add_rewrite_rule with bottom priority doesn’t handle the WordPress pages

When you point a rule to anything other than index.php, it gets interpreted as external and written to the .htaccess file. After external rules are parsed, requests get directed to WordPress, which parses the internal rules in php. This is the internal version: function custom_rewrite() { add_rewrite_rule( ‘^(bar|baz|foo-.*)’, ‘index.php?my_var=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘custom_rewrite’ … Read more

POSTS list in WordPress by views

Seems like you already have the custom field for views set up since that’s a phpMyAdmin screenshot. If so, you can use order_by=”post_views_count” in most wp_query based calls. For instance: $args = array( ‘post_type’ => ‘your_post_type’, ‘orderby’ => ‘meta_value_num’, ‘meta_key’ => ‘post_views_count’, ); $query = new WP_Query( $args ); //…and on with the loop <?php … Read more