Skip to main content

Posts

Showing posts from February, 2016

Get post data by slug in wordpress

 <?php $post_slug = 'online-coupons'; $args=array(   'name' => $post_slug,   'post_type' => 'post',   'post_status' => 'publish',   'posts_per_page' => 1,   'caller_get_posts'=> 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) {   echo 'List of Posts';   while ($my_query->have_posts()) : $my_query->the_post(); ?>     <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>     <?php   endwhile; } wp_reset_query();  // Restore global post data stomped by the_post(). ?>

Realted post in custom post type

<?php $post_type = 'car'; $tax = 'sponsorship'; $post_count = 5; $counter = 0; $tax_terms = get_terms($tax); echo 'Related Advice'; if ($tax_terms) {     foreach ($tax_terms as $tax_term) {     $args = array(         'post_type' => $post_type,         "$tax" => $tax_term->slug,         'post_status' => 'publish',         'orderby' => rand     );     $my_query = null;     $my_query = new WP_Query($args);     if( $my_query->have_posts() ) {         echo '<ul class="sponsorship-post-list">';         while ($my_query->have_posts() && $counter < $post_count) : $my_query->the_post(); ?>         <li>          ...

Realted posts in wordpress custom post type

<? php $backup = $post ; $current = $post -> ID ; //current page ID global $post ; $thisPost = get_post_type (); //current custom post $myposts = get_posts ( 'numberposts=3&order=DESC&orderby=ID&post_type=' . $thisPost . '&exclude=' . $current ); $check = count ( $myposts ); if ( $check > 1 ) { ?> <h1 id = "recent" > Related </h1> <div id = "related" class = "group" > <ul class = "group" > <? php foreach ( $myposts as $post ) : setup_postdata ( $post ); ?> <li> <a href=" <? php the_permalink () ?> " title=" <? php the_title () ?> " rel="bookmark"> <article> <h1 class = "entry-title" > <? php the_title () ?> </h1> <div class...

Sent mail in loop in wordpress or php in ajax loading

form.php <?php ?> <script type="text/javascript"> jQuery(document).ready(function(){  jQuery( ".rcontact" ).click(function( event ) { jQuery(this).find('input').prop('checked', true); });   jQuery( ".contactform" ).submit(function( event ) {     url =  "<?php echo admin_url( 'admin-ajax.php' ); ?>";      var data = jQuery( this ).serialize();      jQuery.post(url, data, function(response) {      if(response)      {       if(response == "success")       {         jQuery(".formMsg").html('mail sent');         setTimeout(function(){            // location.reload();          },3000);       }      }    ...

Fetch data with id in wordpress or php

Send data <a href="http://webplanetsoft.com/testing/ba/check-out/?ordernummer=[ordernummer]">button</a> Get data <?php global $wpdb; $numr=$_GET['ordernummer']; $myrows = $wpdb->get_row( " select * from wp_cform where id='$numr'" ); $postcode= $myrows->post_code; $ussnnumr=$myrows->huisnummer; $orderid=$myrows->id; ?>

show payment data in table on amenu to admin panel

// add this to function.php add_action( 'admin_menu', 'register_my_custom_menu_page' ); function register_my_custom_menu_page(){ // $img = get_template_directory_uri().'/images/transection.png'; $img = 'https://www.khokhamobile.com/mobile/icons/payment-icon.png'; //$img = 'http://rajasthantravelguru.com/test/carrental/wp-content/uploads/2015/12/payment-icon.png'; add_menu_page( 'custom menu title', 'Transactions ', 'manage_options', 'Transactions', 'my_custom_menu_page', 'dashicons-cart', 6 ); } function my_custom_menu_page(){ global $wpdb;    echo '<div class="wrap"><div id="icon-tools" class="icon32"></div>';         echo '<h2 style="text-align:center">Transaction Details </h2>';     echo '</div>'; $myrows = $wpdb->get_results( " select * from transaction_table" ); echo ' <table...

Multiple form submiting or multiple ation in php form

<?php if(isset($_REQUEST['submit'])) {     //die('hello'); ?> <form id="submitForm" name="submitForm" action="http://stackoverflow.com/questions/2996806/can-one-form-have-multiple-actions" method="post"> </form> <?php } ?> <script> function submitForm() {   var submitForm = document.forms.submitForm;   submitForm.submit(); } window.init = submitForm(); </script> <form action="" method="post"> <input type="submit" name="submit" /> </form>

Ideal payment in php

<?php global $wpdb; $numr=$_GET['ordernummer']; $myrows = $wpdb->get_row( " select * from wp_cform where id='$numr'" ); $postcode= $myrows->post_code; $ussnnumr=$myrows->huisnummer; $orderid=$myrows->id; ?> <script type="text/javascript"> <!-- Begin var Amount = 4995; var PSPID = "TESTiDEALEASY"; var AM; if (isNaN(Amount))     {         alert("Amount not a number: " + Amount + " !");         AM = "" ;     } else     {         AM = Math.round(parseFloat(Amount)*100);     } var orderID = "1"; mydate = new Date(); tv = mydate.getYear() % 10; orderID = orderID + tv; tv = (mydate.getMonth() * 31) + mydate.getDate(); orderID = orderID + ((tv < 10) ? '0' : '') + ((tv < 100) ? '0' : '') + tv; tv = (mydate.getHours() * 3600) + (mydate.getMinutes() * 60) + mydate.getSeconds(); orderID = orderID + ((tv...

called function and ajax contact or mail function in wordpress

<?php ob_start(); session_start(); /**  * Plugin Name: Wps Custom  * Plugin URI:  * Description: custom plugin for all functions  * Version: 1.0.1  * Author: Webplanetsoft  */ function wps_query_form() {   require_once('template/form.php'); } function wps_query_contact() {   ob_start();   require_once('template/contact.php');   return ob_get_clean(); } function wps_query_checkout() {   ob_start();   require_once('template/checkout.php');   return ob_get_clean(); } function wps_query_mail2() {   if(isset($_POST['submit'])) {        $ordernummer=$_REQUEST['ordernummer'];     $email=$_REQUEST['email'];     $kosten=$_REQUEST['kosten'];     $beste=$_REQUEST['beste'];     $ons=$_REQUEST['ons'];     $besparing=$_REQUEST['besparing'];   $baseurl = site_url()."/wp-content/plugins/wps_custom/image/";    $conten...

Fetch data in wordpress with foreach loop

<?php $vin='104'; global $wpdb;    $myrows = $wpdb->get_results( " select * from wp_cform where id='$vin'" ); foreach($myrows as  $data)     { $ordernummer= $data->id; echo $data->email; echo $data->gasverbruik; echo $data->geen; echo $data->fgroup; echo $data->fselect;     } ?> <br/> <?php echo "$ordernummer"; ?>

Show or Display Related Posts in WordPress without a Plugin

<?php //for use in the loop, list 5 post titles related to first tag on current post $tags = wp_get_post_tags($post->ID); if ($tags) { echo 'Related Posts'; $first_tag = $tags[0]->term_id; $args=array( 'tag__in' => array($first_tag), 'post__not_in' => array($post->ID), 'posts_per_page'=>5, 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php endwhile; } wp_reset_query(); } ?>

Ajax Email or Contact form In Wordpress

Index.php Code <?php function wps_query_form() {     require_once('template/form.php'); } function wps_home_form_callback() {     $req = $_REQUEST;             add_filter( 'wp_mail_content_type', 'wps_set_html_content_type' );        $to      = "$adminmail,$email";     $subject = 'Uw aanmelding bij BespaarAutomatisch.nl';        wp_mail( $to, $subject, $body );     remove_filter( 'wp_mail_content_type', 'wps_set_html_content_type' );     echo "success";     exit(); } function wps_set_html_content_type() {     return 'text/html'; } function wps_replace_string($content,$aStrings) {     if($aStrings)     {         foreach($aStrings as $aKey => $aString)       ...

Get data From Custom Post

<div class="mm-top-box"> <?php $args = array( 'post_type' => 'customerstories', 'posts_per_page' => 1 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post();   ?> <h1 class="heading"><a href="#">Customer Stories</a></h1> <div class="mm-img"><?php if ( has_post_thumbnail() ) { ?>    <a class="thumbnail" href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> <?php } ?></div> <div class="mm-content"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a><div class="lm"> <a href="<?php the_permalink() ?>" rel="bookmark" title=...

pagination in wordpress post or custom posts In Loop

<?php   $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;   $custom_args = array(       'post_type' => 'bollywood',       'posts_per_page' => 2,       'paged' => $paged     );   $custom_query = new WP_Query( $custom_args ); ?>   <?php if ( $custom_query->have_posts() ) : ?>     <!-- the loop -->     <?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>     <h1>Your Data</h1>     </div>       <?php endwhile; ?>     <!-- end of the loop -->     <!-- pagination here -->     <?php       if (function_exists(custom_pagination)) {         custom_pagination($custom_query->max_nu...