Storing form data into wordpress database [closed]

This is a simple code to add a form in a page: add_shortcode( ‘myform’, ‘add_myform’ ); function add_myform( $atts ) { if ( isset( $_POST[‘myname’] ) ) { $myname = $_POST[‘myname’]; update_option( ‘myname’, $myname ); } else { $myname = get_option( ‘myname’ ); } $myform = “<form method=’post’ action=”>”; $myform .= “<input type=”text” name=”myname” value=”” … Read more

Post rank by views

Is there any specific reason you are using $wpdb? You can do the same with WP_Query which is always recommended. So if your meta key for counting post views is views then you can run this WP_Query to return top viewed posts. You can also limit results by posts_per_page. <?php $args = array( ‘post_type’ => … Read more

how to display the page content in popup window?

I use Plugin for display the page content in popup window Check official website for live demo Plugin advantage -Easy to configuration. -Unblockable. -HTML Editor to add popup contact. -Plugin supports Chrome, Firefox, Safari and IE 7,8,9,10

Updating post_views_count on publish [duplicate]

So this is the code I earlier posted. // Create custom field on post publish function wpse_custom_field_on_publish( $new, $old, $post ) { if ( $new == ‘publish’ && $old != ‘publish’ && !get_post_meta( $post->ID, ‘post_views_count’, true ) ) { add_post_meta( $post->ID, ‘post_views’, rand(829, 1013), true ); } } add_action( ‘transition_post_status’, ‘wpse_custom_field_on_publish’, 10, 3 ); Let … Read more

How to split the loop every 2 and 5 results? [closed]

Yes you can do that using $wp_query->current_post inside the loop. It returns the current posts index number inside the loop (starting form 0). Have a look at the following code block <?php global $wp_query; while(have_posts()){ the_post(); the_title(); //do your other stuff if($wp_query->current_post==1){ //do what you want to do after 2nd post }else if($wp_query->current_post==5){ //do what … Read more

How to display Custom taxonomy on custom post listing page [duplicate]

You can get terms by posts with this functions. $term_list = wp_get_post_terms($post->ID, ‘my_taxonomy’, array(“fields” => “ids”)); And echo or use different with foreach(). This tip get terms with ID. You can get another properties. wp_get_post_terms() in codex. Get term by id and taxonomy => $term = get_term($term_id, ‘my_taxonomy’); Get term name by id => $term->name; … Read more

Shortcode conversion to hrml when post is published

You can use the pre_post_update filter hook to achieve this. Unfortunately the Codex isn’t very good for this hook, but it’s a simple enough one to understand and can be found in wp-includes/post.php on line 3335 (WP 4.1). add_filter( ‘pre_post_update’, ‘my_replace_shortcode’, 2, 99 ); function my_replace_shortcode( $post_id, $data ){ if(strpos($data[‘post_content’], ‘[myshorcode param1=”‘) !== false) : … Read more

Woocommerce: Making email clickable [closed]

This is really a vanilla PHP/HTML question, but for what it’s worth: <?php if ( $email = get_post_meta( $order->id, ‘_billing_email’, true ) ) : ?> <li> <span><?php _e( ‘Email:’, ‘dokan’ ); ?></span> <a href=”https://wordpress.stackexchange.com/questions/178783/mailto:<?php echo esc_attr( $email ) ?>”><?php echo esc_html( $email ) ?></a> </li> <?php endif ?> <?php if ( $phone = get_post_meta( $order->id, … Read more