if statement on database query
On your if(), it should be like this: if (!($wpdb->get_row(“SELECT voter_ip FROM ” . $wpdb->prefix . “voter_ips WHERE post_id = $post_id AND voter_ip = ‘$voter_ip'”) Notice the quotation mark added on $voter_ip.
On your if(), it should be like this: if (!($wpdb->get_row(“SELECT voter_ip FROM ” . $wpdb->prefix . “voter_ips WHERE post_id = $post_id AND voter_ip = ‘$voter_ip'”) Notice the quotation mark added on $voter_ip.
Your template code includes $wpdb->print_error(). This function prints the last database error between [ and ] brackets, and the executed SQL code. But if there is no error, you just see the empty brackets and the SQL. $wpdb->show_errors() is used to enable displaying of database errors. If you want to see all database errors, you … Read more
You can add extra rules right after the ^index\.php$ line via the WP_Rewrite class, more specifically the add_external_rule() method. They are added to the non_rewrite_rules array, which is written in the mod_rewrite_rules() method. This is a very simple example. You should still flush the rewrite rules (once), either on plugin activation or by visiting the … Read more
This will not work because you call example.com/markers.php directly, and that file does not load anything from WordPress, like the $wpdb object. You can include wp-load.php, but this might break if you move the WordPress installation to somewhere else. To be more in line with how Ajax calls in WordPress should be made, you should … Read more
wp_localize_script is the “WordPress way” to pass data from php to javascript. See this post by Otto for more info.
If you followed the install instructions with that theme, one of the steps was to add the WP e-Commerce plugin and activate it. wpsc_cart_item_count is a function of that plugin, so it is likely not currently activated.
Remove the cat parameter from your query and name your template file category.php From the WordPress Codex on Template Hierarchy; 1. category-{slug}.php – If the category’s slug were news, WordPress would look for category-news.php 2. category-{id}.php – If the category’s ID were 6, WordPress would look for category-6.php 3. category.php 4. archive.php 5. index.php The … Read more
There’s the wp_mail() function in WordPress. The headers have to be added as array without trailing \n\r or similar. Example wp_mail( ‘[email protected]’, ‘Hello World!’, ‘Just saying…’, array( ‘MIME-Version: 1.0’, ‘Content-type: text/html; charset=iso-8859-1’, sprintf( ‘From: %s <no-reply@%s>’, get_bloginfo(‘name’), site_url() ), sprintf( ‘X-Mailer: PHP/%s’, phpversion() ), ) ); To change the content type you could as well … Read more
You can select between Full text and Summary in the Reading settings: If you select the Summary, then a) To control the number of words in the feed summary you can use: add_filter(‘excerpt_length’,’custom_excerpt_length’); function custom_excerpt_length( $num_words ){ return 30; // number of words to show } The default number of words in the summary is … Read more
Because of backwards compatibility. You can use the same callback for multiple filters. Inside of that callback you should use current_filter() to determine the context. But some plugins use the number of passed arguments instead. Changing that would break these plugins. That’s why you should always use the API (here: current_filter()) and not some made-up … Read more