Equivalent of admin.php for public pages

Even if admin-ajax.php and Ajax API were created to be used in ajax requests, they can be used in normal http requests with no issues, just be aware that is_admin() will be true even if user is not logged and the request is done from frontend. What you have to do is create a callback … Read more

phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’

From what I can see, you are inserting data in table wp_commentmeta. However the column meta_id has a Primary Key restriction. You can see the table definition at http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta As meta_id has a Primary Key restriction, this column may only hold unique values. The insert statements you have posted show only unique values for meta_id, … Read more

Echo out element to another page.

Well, writing echo ninja_forms_field_submission_left_display( $field_id, $data ); into a template should do it, if $field_id and $data is correct. Creating a shortcode should be equally trivial: function field_sc_wpse_145003($atts,$content) { if (!isset($atts[‘field_id’])) return; return ninja_forms_field_submission_left_display( $atts[‘field_id’], $atts ); } add_shortcode(‘fieldfc’,’field_sc_wpse_145003′); echo do_shortcode(‘[fieldfc field_id=”abc” default_content=”def”]’);

How to get comment_ID by post_ID in wordpress

Use get_comments( $args ) to get all the comments for a post. $args= array( ‘author_email’ => ”, ‘ID’ => ”, ‘karma’ => ”, ‘number’ => ”, ‘offset’ => ”, ‘orderby’ => ”, ‘order’ => ‘DESC’, ‘parent’ => ”, ‘post_id’ => 0, ‘post_author’ => ”, ‘post_name’ => ”, ‘post_parent’ => ”, ‘post_status’ => ”, ‘post_type’ => … Read more

Looping through 3 recent posts but separating them into separate divs

This isn’t really a WordPress question, but all you need to do is setup a counter for the class integer that you want, as follows: <?php // Create a variable to hold our custom Loop results $excludes = array(‘4135’); $frontpageposts = get_posts( array( ‘numberposts’ => 3, // only the 3 latest posts ‘post__not_in’ => $excludes … Read more

Displaying Event within two given time frames

Querying on the meta data table is slow, and as since it’s also used for general data, you need to be careful about your date format if you’re storing dates there. For instance, with dmY format: 01112014 ( 1st November 2014 ) 11012014 ( 11th January 2014 ) 12052014 ( 12th May 2014 ) is … Read more

Taxonomy term count

You can use WP_Query Methods and Properties to accomplish this. $wp_query->found_posts will return the amount of posts within the term while $wp_query->queried_object->name will return the name of the term currently displayed. You can now just paste all these together to display 18 free resources $taxcount = $wp_query->found_posts; $taxname = $wp_query->queried_object->name; printf(__( ‘%s %s resources’ ), … Read more

Custom navigation menu with awsAccordion

After reading PHP and wordpress codex i achieved what i wanted, by making a walker class. Here is the code class Hambos_Walker_Nav_Menu extends Walker_Nav_Menu { function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat(“\t”, $depth); if ($depth == 0): $output .= “\n$indent <div>\n”; else: $output .= “\n$indent <ul>\n”; endif; } … Read more