Showing posts with label Wordpress Meta Description Not Showing in Frontend. Show all posts
Showing posts with label Wordpress Meta Description Not Showing in Frontend. Show all posts

Wordpress Dropdown Category Ajax Search

WordPress Drop down Category Ajax Search


Today Discussed wordpress dropdown category list ajax search without plugin and create shortcodes follows briefly discussed. normally any search field or any one task mostly used plugin activate list of more then plugin this the wordpress large file and buy the plugin. So just avoid plugin hardcode this wordpress is category list ajax search follows code.

Wordpress Dropdown Category Ajax Search
Wordpress Dropdown Category Ajax Search


shortcodes.php

function ajax_filter_search($atts, $content = null) {
    extract(shortcode_atts(array(
  'post_type'    => AFSAdmin::afs_retrieve('_general_post_type'),
  'post_tax'     => AFSAdmin::afs_retrieve('_general_post_taxonomy'),
  'posts_per_page'  => AFSAdmin::afs_retrieve('_general_posts_per_page'),
  'filter_type'   => '',
  'filter_by'     => '',
  'filter_months'    => '',
  'filter_years'    => '',
  'filter_withPDF'   => '',
  'offset'     => 0,
    ), $atts));

ajax filter search what ever search stored array format year month and pdf taxnonmy etc.,  and included functions and follows code.

if($post_type == '') { } else { $afs_args .=' post_type="'.$post_type.'" '; }
 if($posts_per_page == '') { } else { $afs_args .=' posts_per_page="'.$posts_per_page.'" '; }
 if($filter_by == '') { } else { $afs_args .=' filter_by="'.$filter_by.'" '; }
 if($filter_months == '') { } else { $afs_args .=' filter_months="'.$filter_months.'" '; }
 if($filter_years == '') { } else { $afs_args .=' filter_years="'.$filter_years.'" '; }
 if($filter_withPDF == '') { } else { $afs_args .=' filter_withPDF="'.$filter_withPDF.'" '; }
 if($offset == '') { } else { $afs_args .=' offset="'.$offset.'" '; }
  
 if($filter_type == '') { 
  $all='all'; 
  $filter_type_count = 999;
 } else { 
  $afs_args .=' filter_type="'.$filter_type.'" '; 
  $all=$filter_type;
  $filter_type_array = explode(',',$filter_type);
  $filter_type_count = count($filter_type_array);
 }
  
 $text = '';
 $i = 1;
ajax filter conditions check else and true or false conditions check and then show this html code included same php format follows.

$text .= '<div id="afs-wrapper">';
 $text .= ' <div class="press-releases">';
 $text .= '  <form id="newsForm">';
 $text .= '   <div class="row">';
 
 
 $text .= '    <div class="col-xs-1TableRowItem2">';
 
   $text .= '       <label for="category"><strong>Display:&nbsp;</strong></label>';
   $text .= '       <select name="category">';
   $text .= '        <option value="all">All</option>';
             $terms = get_terms($taxonomy, $args = array('orderby'=>'id') );
             if($terms) {
             
              foreach($terms as $term) {
               if(isset($filter_type_array)) {
                if(in_array($term->slug,$filter_type_array)) {
                 if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
                }
               } else {
                if($term->name == 'Uncategorized') { continue; }
                 $text .= '<option value="'.$term->slug.'">'.$term->name.'</option>';
               }
              }
             }
   $text .= '       </select>';
   $text .= '      </div>';
   $text .= '     </div>';
  }
  } 
 
function.php

if (!function_exists('myplugin_ajaxurl')) {
 add_action('wp_head', 'myplugin_ajaxurl');
 
 function myplugin_ajaxurl() {
 
    echo '<script type="text/javascript">
      var ajaxurl = "' . admin_url('admin-ajax.php') . '";
      var scriptpath = "' . site_url() . '";
    </script>';
 }
}

if (!function_exists('my_action_callback')) {
 // Ajax call to sort PRs
 function my_action_callback() {  
 
  // Get the values:
  $post_type  = AFSAdmin::afs_retrieve('_general_post_type');
  $posts_per_page = AFSAdmin::afs_retrieve('_general_posts_per_page');
  $filter_type  = $_POST['filingType'];
  $filter_by   = $_POST['filterBy'];
  $filter_months  = $_POST['filterMonths'];
  $filter_years  = $_POST['filterYears'];
  $filter_withPDF = $_POST['withPDF'];
 
  $offset    = $_POST['page'];
  
  echo do_shortcode('[afs_feed post_type="'.$post_type.'" posts_per_page="'.$posts_per_page.'" offset="'.$offset.'" filter_type="'.$filter_type.'" filter_by="'.$filter_by.'" filter_months="'.$filter_months.'" filter_years="'.$filter_years.'" filter_withPDF="'.$filter_withPDF.'"]');
 
  exit;
 
 }
 
 add_action('wp_ajax_my_action', 'my_action_callback');
 add_action('wp_ajax_nopriv_my_action', 'my_action_callback');
}

/*******************************************************************
* AJAX IN ADMIN
********************************************************************/
if (!function_exists('get_selected_taxonomy')) {
 // Ajax call to get taxnomy values
 function get_selected_taxonomy() {  
 
  // Get the values:
  $cur_post_tax = AFSAdmin::afs_retrieve('_general_post_taxonomy');
  $post_type   = $_POST['option'];
  
  $taxonomy_objects = get_object_taxonomies($post_type, 'objects');
  
  if($taxonomy_objects) {
   foreach($taxonomy_objects as $tax) {
    $sel = '';
    if($tax->name == 'post_format') {
     continue;
    } else {
     if($tax->name == $cur_post_tax) { $sel = 'selected="selected"'; }
     echo '<option value="'.$tax->name.'" '.$sel.'>'.$tax->label.'</option>';
    }
   } 
  } else {
   echo '<option value="none" '.$sel.'>None</option>';
  }
 
  exit;
 
 }
 
 add_action('wp_ajax_get_selected', 'get_selected_taxonomy');
 add_action('wp_ajax_nopriv_get_selected', 'get_selected_taxonomy');
}

/*add_action( 'admin_footer', 'my_action_javascript' ); // Write our JS below here

function my_action_javascript() { ?>
 <script type="text/javascript" >
 jQuery(document).ready(function($) {
  
  $('#afs-form input#submit').on({
   click: function(){
    
    //return false;
    
   }
  });
  
  var data = {
   'action': 'my_action',
   'whatever': 1234
  };

  // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
  jQuery.post(ajaxurl, data, function(response) {
   console.log('Got this from the server: ' + response);
  });
 });
 </script> <?php
}*/
?>

How to related Post show in wordpress

How to related Post show in wordpress

How to related Post show in wordpress
How to related Post show in wordpress

How to related post show in wordpress is today discussed. Blog posting and any other post related post showing index page or any other page showing wordpress themes folder wp-contents and new folder create includes and showing code follows.

/public_html/wp-content/themes/themsname/includes/post-formats/related-posts.php

<?php
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();

foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts' => 4, // these are the number of related posts we want to display
'caller_get_posts'=>1,
'ignore_sticky_posts' => 1 // to exclude the sticky post
);
// WP_Query takes the same arguments as query_posts
$related_query = new WP_Query($args);
if ($related_query->have_posts()) {
?>

<?php $blog_related = of_get_option('blog_related'); ?>
<?php if($blog_related){?>
<h3><?php echo of_get_option('blog_related'); ?></h3>
<?php } else { ?>
<h3><?php _e('Related Posts','drivingSchool');?></h3>
<?php } ?>
<ul class="related-posts">
<?php
while ($related_query->have_posts()) : $related_query->the_post();
?>
<li>
<?php if(has_post_thumbnail()) { ?>
<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full'); //get img URL
$image = aq_resize( $img_url, 140, 100, true ); //resize & crop img
?>
<figure class="featured-thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><img src="<?php echo $image ?>" alt="<?php the_title(); ?>" /></a>
</figure>
<?php } ?>

<h6 class="relatedPost"><a href="<?php the_permalink() ?>" > <?php the_title();?> </a></h6>
</li>
<?php
endwhile;
?>
</ul>
<?php }
wp_reset_query();
}
?>
Single.php

Which page showing related  post just copy and past this code. and more wordpress functions click here

<?php get_template_part( 'includes/post-formats/related-posts' ); ?>
<?php comments_template('', true); ?>


Categorized list of WordPress functions

Categorized list of WordPress functions that are commonly used when building, updating and maintaining templates.

Wordpress Basics Temlate Files and updates customized data and categorized listed and funcation loop functions and basics function and default functions follows.

Categorized list of WordPress functions
Categorized list of WordPress functions


Basic Template Files

File Name Description
style.css style sheet file
index.php   ome page file
header.php header content file
single.php single post page file
archive.php archive/category file
searchform.php search form file
search.php search content file
404.php error page file
comments.php  comments template file
footer.php footer content file
sidebar.php sidebar content file
page.php single page file
front-page.php latest posts or static page
tag.php display tags in archive format
category.php display categories in archive format


Header Functions

Function Description

<?php site_url(); ?>   root url for website

<?php wp_title(); ?> title of specific  post/page

<?php bloginfo('name'); ?> title of site

<?php bloginfo('description'); ?> site description

<?php get_stylesheet_directory(); ?> stylesheet folder location

<?php bloginfo('stylesheet_url'); ?> style.css file location

<?php bloginfo('pingback_url'); ?>  pingback url

<?php bloginfo('template_url'); ?> template folder path

<?php bloginfo('version'); ?> wordpress blog version

<?php bloginfo('atom_url'); ?> atom url

<?php bloginfo('rss2_url'); ?>  rss2 url

<?php bloginfo('url'); ?> root url for website

<?php bloginfo('html_type'); ?> html version

<?php bloginfo('charset'); ?> charset parameter

Navigation Menu

Default Navigation Menu

<?php wp_nav_menu(); ?>

Specific Navigation Menu

<?php wp_nav_menu( array('menu' => 'Project Nav' )); ?>

Category Based Navigation

<ul id="menu">

<li <?php if(is_home()) { ?> class="current-cat" <?php } ?>>

<a href="<?php bloginfo('home'); ?>">Home</a></li>

<?php wp_list_categories('title_li=&orderby=id');?>

</ul>

Page Based Navigation

<ul id="menu">

<li <?php if(is_home()) { ?> class="current-page-item" <?php } ?>>

<a href="<?php bloginfo('home'); ?>">Home</a></li>

<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

</ul>

The Loop

Basic Loop

<?php if(have_posts()) { ?>

<?php while(have_posts()) { ?>

<?php the_post(); ?>

<?php // custom post content code for title, excerpt and featured image ?>

<?php } // end while ?>

<?php } // end if ?>

Template Functions

Function Description

<?php the_content(); ?> content of posts/pages

<?php if(have_posts()): ?> check if there are posts

<?php while(have_posts()): the_post(); ?> shows posts

<?php endwhile; ?> closes loop

<?php endif; ?> closes if

<?php get_header(); ?> header.php file contents

<?php get_sidebar(); ?> sidebar.php file contents

<?php get_footer(); ?> footer.php file contents

<?php the_time('m-d-y'); ?> the date is '08-18-07'

<?php comments_popup_link(); ?> link to comments of post

<?php the_title(); ?> title of post/page

<?php the_permalink(); ?> url of post/page

<?php the_category(); ?> category of post/page

<?php the_author(); ?> author of post/page

<?php the_ID(); ?> id of post/page

<?php edit_post_link(); ?> edit link of post/page

<?php wp_list_bookmarks(); ?> links from blogroll

<?php comments_template(); ?> comment.php file contents

<?php wp_list_pages(); ?> list all pages

<?php wp_list_categories(); ?> list all categories

<?php next_post_link('%link'); ?> url to next post

<?php previous_post_list('%link'); ?> url to previous post

<?php get_calendar(); ?> show post calendar

<?php wp_get_archives(); ?> list of archive urls

<?php posts_nav_link(); ?> next and previous post link

<?php rewind_posts(); ?> rewinds post for a second loop



Extra Functions

Function Description

/%postname%/ custom permalinks

<?php include(TEMPLATEPATH . '/x'); ?> include file from template folder

<?php the_search_query(); ?> value returned from search from

<?php _e('Message'); ?> return translated text from translate()

<?php wp_register(); ?> register link

<?php wp_loginout(); ?> login/logout link

<!--nextpage--> divide content into pages

<!--more--> cut off content and create link to full
post


<?php wp_meta(); ?> admin meta data

<?php timer_start(); ?> start page timer (header.php)

<?php timer_stop(1); ?> time to load the page (footer.php)

<?php echo get_num_queries(); ?> show queries executed to generate
page


Wordpress Meta Description Not Showing in Frontend

Wordpress Meta Description Not Showing in Frontend

Today Discussed wordpress meta description Not showing seo yoast plugin problem. How to handle this task. First one seo yoast set up this plugin.

Wordpress Meta Description Not Showing in Frontend
Wordpress Meta Description Not Showing in Frontend


Seo Yoast Plugin sometime not working in meta description is not showing in frontend this problem seo issue is empty meta description. This case handle is very simple. following code copy and paste header.php



<meta name="description" content="<?php
 // if home page output blog name and description
 if (is_home()) { bloginfo('name'); echo " - "; bloginfo('description');}
 // if single page output either excerpt if available or post title
 elseif (is_single()) {
 $custommeta = get_post_meta($post->ID, "MetaDescription", true);
 // checks ot see if the custom field MetaDescription is not empty
 if ($custommeta !=='') {echo $custommeta;}
 // check if excerpt exists for the post and output it if it does
 elseif (!empty($post->post_excerpt)) {the_excerpt();}
 // if there's no custom field or excerpt output the post title
 else {single_post_title('', true);}
 }
 // if category page output the category description
 elseif (is_category()) {echo category_description();}

 // if it's any other page display this generic description
 else { echo 'Add your own generic site description here';}
 ?>"
/>
after check it your site view source now showing meta description. more details please visite developerinvention.in