Category: Wordpress

How To Reinstall WordPress Core Files without losing content via FTP

Way to How To Reinstall WordPress Core Files without losing content via FTP

  1. After logging into FTP dashboard ,drag all WordPress Core Files inside /public_html
  2. Download the latest version of WordPress
  3. Download ENTIRE WordPress files of your site
  4.  
  5. Open your Downloaded WordPress files of your site  say /quarantine is your entire site folder.

Open wp-config.php  and copy information as shown below

 

6.Navigate to your public_html directory and you should see a file called wp-config-sample.php, right-click on this file and Edit, open the file in Notepad then fill in your database name, database user, and database user password and save it as shown below.

 

7.Now  right-click on wp-config-sample.php choose Rename, and then name the file just wp-config.php as shown below. .

 

8.Now upload your  theme from here /quarantine/wp-content/themes to /public_html/wp-content/themes directory as shown below. .

ftp upload backup theme wordpress

 

This will complete Reinstall WordPress Core Files without losing content via FTP

Insert ads after second paragraph of single post content without wordpress plugin

How to insert ads within your post content after second paragraph in wordpress without wordpress plugin

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to to Insert ads after second paragraph of single post content without wordpress plugin

add_filter( ‘the_content’, ‘prefix_insert_post_ads’ );

function prefix_insert_post_ads( $content ) {

$ad_code = ‘<div>YOUR AD CODE</div>’;

if ( is_singular() && ! is_admin() ) {
return prefix_insert_after_paragraph( $ad_code, 2, $content );
}

return $content;
}

function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
$closing_p = ‘</p>’;
$paragraphs = explode( $closing_p, $content );
foreach ($paragraphs as $index => $paragraph) {

if ( trim( $paragraph ) ) {
$paragraphs[$index] .= $closing_p;
}

if ( $paragraph_id == $index + 1 ) {
$paragraphs[$index] .= $insertion;
}
}

return implode( ”, $paragraphs );
}

 

Note replace above YOUR AD CODE with your adsense code

This will Insert ads after second paragraph of single post content without wordpress plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

 

WordPress Dynamic XML Sitemap Without Plugin

WordPress Dynamic XML Sitemap Without Plugin

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to to Add WordPress XML Sitemap Without Plugin

 

add_action(“publish_post”, “eg_create_sitemap”);
add_action(“publish_page”, “eg_create_sitemap”);
function eg_create_sitemap() {
$postsForSitemap = get_posts(array(
‘numberposts’ => -1,
‘orderby’ => ‘modified’,
‘post_type’ => array(‘post’,’page’),
‘order’ => ‘DESC’
));
$sitemap = ‘<?xml version=”1.0″ encoding=”UTF-8″?>’;
$sitemap .= ‘<?xml-stylesheet type=”text/xsl” href=”sitemap-style.xsl”?>’;
$sitemap .= ‘<urlset xmlns=”https://www.sitemaps.org/schemas/sitemap/0.9″>’;
foreach($postsForSitemap as $post) {
setup_postdata($post);
$postdate = explode(” “, $post->post_modified);
$sitemap .= ‘<url>’.
‘<loc>’. get_permalink($post->ID) .'</loc>’.
‘<priority>1</priority>’.
‘<lastmod>’. $postdate[0] .'</lastmod>’.
‘<changefreq>daily</changefreq>’.
‘</url>’;
}
$sitemap .= ‘</urlset>’;
$fp = fopen(ABSPATH . “sitemap.xml”, ‘w’);
fwrite($fp, $sitemap);
fclose($fp);
}

 

Next copy existing template  as  /home/username/public_html/wp-content/themes/currently_active_theme/

so for us our path is /SHAREASKCOM_1/wp-content/themes/share-askchild

Next name copied file as sitemap here  /home/username/public_html/wp-content/themes/currently_active_theme/sitemap

so for us our path is /SHAREASKCOM_1/wp-content/themes/share-askchild/sitemap

Now find </header> in the new file sitemap and paste below code after </header>

 
<div class=”html-sitemap”>

<h2>Pages:</h2>
<ul class=”sitemap-pages”>
<?php
//https://codex.wordpress.org/Function_Reference/wp_list_pages
wp_list_pages(‘exclude=889&title_li=’); //***Exclude page Id, separated by comma. I excluded the sitemap of this blog (page_ID=889).
?>
</ul>

<h2>Posts:</h2>
<ul>
<?php
//https://codex.wordpress.org/Function_Reference/get_categories
$cats = get_categories(‘exclude=’); //***Exclude categories by ID, separated by comma if you like.

foreach ($cats as $cat) {
echo ‘<li class=”category”>’.”\n”.'<h3><span class=”grey”>Category: </span>’.$cat->cat_name.'</h3>’.”\n”;
echo ‘<ul class=”cat-posts”>’.”\n”;

//https://codex.wordpress.org/Function_Reference/query_posts
query_posts(‘posts_per_page=-1&cat=’.$cat->cat_ID); //-1 shows all posts per category. 1 to show most recent post.

//https://us3.php.net/while ; https://codex.wordpress.org/The_Loop ; https://codex.wordpress.org/The_Loop_in_Action
//https://codex.wordpress.org/Function_Reference/the_time ; https://codex.wordpress.org/Function_Reference/the_permalink
//https://codex.wordpress.org/Function_Reference/the_title ; https://codex.wordpress.org/Function_Reference/comments_number
while(have_posts()): the_post();
//https://codex.wordpress.org/Function_Reference/get_the_category
$category = get_the_category();
//Display a post once, even if it is in multiple categories/subcategories. Lists the post in the first Category displayed.
if ($category[0]->cat_ID == $cat->cat_ID) {?>
<li><?php the_time(‘M d, Y’)?> &raquo; <a href=”<?php the_permalink() ?>” title=”Permanent Link to: <?php the_title(); ?>”>
<?php the_title(); ?></a> (<?php comments_number(‘0’, ‘1’, ‘%’); ?>)</li>
<?php } //endif
endwhile; //endwhile
?>
</ul>
</li>
<?php } ?>
</ul>
<?php
//https://codex.wordpress.org/Function_Reference/wp_reset_query
wp_reset_query();
?>
<h2>Archives:</h2>
<ul class=”sitemap-archives”>
<?php
//https://codex.wordpress.org/Function_Reference/wp_get_archives
wp_get_archives(‘type=monthly&show_post_count=true’);
?>
</ul>
</div>

 

This will give us WordPress XML Sitemap Without Plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

Remove query strings from static resources without wordpress plugin

Way toRemove query strings from static resources without wordpress plugin

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to to Remove query strings from static resources without wordpress plugin

 

function _remove_script_version( $src ){
$parts = explode( ‘?ver’, $src );
return $parts[0];
}
add_filter( ‘script_loader_src’, ‘_remove_script_version’, 15, 1 );
add_filter( ‘style_loader_src’, ‘_remove_script_version’, 15, 1 );

This will Remove query strings from static resources without wordpress plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

Add Defer and Async Attributes to Render Blocking Javascript in wordpress without plugin

How to Add Defer and Async Attributes to Render Blocking Javascript

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to to Add Defer and Async Attributes to Render Blocking Javascript

function js_async_attr($tag){

# Add async to all remaining scripts
return str_replace( ‘ src’, ‘ defer=”defer” src’, $tag );
}
add_filter( ‘script_loader_tag’, ‘js_async_attr’, 10 );

This will Add Defer and Async Attributes to Render Blocking Javascript in wordpress without plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

How to Remove the […] from the excerpt without plugin

Steps to Remove the […] from the excerpt without plugin

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Put this below code in your functions.php to remove the […] at the end of the excerpt.

function trim_excerpt($text) {
return substr($text, 0, -11);
}
add_filter(‘get_the_excerpt’, ‘trim_excerpt’);

This will remove ellipsis in wordpress excerpt without plugin

Let me know besumitbe@gmail.com/skype-bpshbp if you have any Query

 

Internal Link Building with SEO Smart Links

SEO Smart Links  Internal Link Building Tricks

what are smart links

So one of the things that helps with on-page SEO is internal building. I’m going to show you plugin that does this automatically for you which is also referred as seo auto linker. Let’s check it out! I’m going to share with you a plugin that I like to use called SEO Smart Links and to genuinely demonstrate how the results of this work I’m going to go to a website called www.Share-ask.com and

I’m going to go to the lesson’ https://share-ask.com/wordpress-tutorial-manually-upgrade-wordpress-website-using-ftp-filezillacpanel/’ and you can see right here there are links that are auto generated, say for’ WordPress.org ‘.

These are all wordpress automatic links or smart links that are autogenerated with SEO Smart Links plugin that I use and these are basically is linked to pages within the same website and internal post.This is very important because it can help your readers stay within your website and continue to read content and it helps with your search engine optimization.

So, let’s just basically demonstrate you how to install this SEO Smart Links.

You’ll want to go inside your dashboard and you’ll wishes to click on’ PLUGINS’ and click’ ADD NEW’ and then you’ll wishes to form in “seo smart links”. Okay so now when you get to SEO Smart Links and you search for it you’ll wishes to stimulate assured that you pick the right ones. There’s one about SEO Smart Links+ and seo smart links premium and the one you want to select is by Vladmir Prelovac, it’s the second one, version 2.78.

Steps to install this SEO Smart Links.

We’re going to go ahead and click’ INSTALL NOW ‘, click’ OK’ and then click’ ACTIVATE ‘. Okay so that’s all you have to do with SEO Smart Links. It basically will read your blog post titles or page titles and any time that keyword appears up it’s going to basically link to it. So for example, I have a webpage called “Insanity Nutrition Guide” and I want keyword Nutrition Guide to be linked everywhere this word occurs in my website .

Now every single hour that this word comes up in a blog post or blog page it’s going to automatically link to this keyword . So whatever page you want to autolink just create a certain name, so for example, if i want to link  to this keyword Workout Program . Then with the help of SEO Smart Link internal building Plugin you can see it automatically link any keyword you want to link. SEO Smart Links actually do your internal linking an easier process so check it out ..

SEO Smart Link internal link building wordpress plugin tutorial

As found on Youtube

Disable WordPress heartbeat API with OR without Plugin

 

Way to Disable WordPress heartbeat API with OR without Plugin

 

WordPress is the standard choice for online content management structures. Those who are acquainted with CPanel software and Apache servers know how easy it is to INSTALL WordPress using either 1 Click Installer or manually  . WordPress is by default a  optimized Hypertext Preprocessor (PHP)primarily based CMS. But nevertheless with time and new additions a number of the features of WordPress which makes  CPU  exhausted, specifically for shared hosting servers or for those folks who are using loose servers.

To solve this intensive CPU usage WordPress has new features called WordPress heartbeat. The wordpress heartbeat interval is essentially a background script which keeps strolling and is an integral a part of WordPress’ capability. Let’s discover ways to disable WordPress heartbeat API to reduce CPU usage.

what is WordPress heartbeat API?

Disable WordPress heartbeat API
The name Heartbeat comes from the fact that just like a beating heart which generates a pulse the WordPress heartbeat API additionally generates a pulse i.e. a tick which is associated with extraordinary moves which are completed periodically. WordPress Heartbeat API is JavaScript based totally and it allows WordPress to have cross communication among the server and browser. It was first of all added in WordPress 3.6, it enables in put up revision monitoring, auto saving of posts at the same time as writing and user session management.

How does the heart beat API functions?
The /wp-admin/admin-ajax.php wordpress script is utilized by the WordPress heartbeat API to run AJAX calls. This is very beneficial because it helps WordPress to hold track of everything being executed on the dashboard. But the dark side is that it continues sending requests even if the web page won’t be in use.

 

How does the problem start?
The trouble starts when the WordPress heartbeat API  begins calling the admin-ajax.php wordpress script file frequently, this can result in high CPU utilization.

Even when a person has only logged into WordPress admin dashboard and is working on different tabs or they’ve minimized the WordPress live window then also the admin-ajax.php file  is requested again and again after a fixed interval of time.

The quantity of script executions even if doing nothing is pretty high and can cause CPU aid over-usage and can crash the live site. A simple method to this hassle is to disable or selectively disable the WordPress heartbeat API.

 

How to disable WordPress heartbeat API to lessen CPU usage : The technique.

To disable the heart beat API you need to find the functions.php first. For doing so below steps :

After logging into WordPress dashboard go to Appearance > Editor from the menu at the left hand side.

Now locate the functions.php file

The location to the file may look like : /home/username/public_html/wp-content/themes/currently_active_theme/functions.php

Make a local backup of this file in case anything goes wrong and you may need to revert to previous stable code.

click on it to begin editing it.

Be aware : you can both completely disable WordPress Heartbeat API or you may select to selectively disable it.

 

Steps to disable WordPress Heartbeat API completely :

Add the following code at the beginning of functions.php just after this tag <?php  

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
 wp_deregister_script('heartbeat');
}

The above code disables heartbeat site wide and most of the features of WordPress that had been usually available could not work when this code has been added. However this one promises the maximum decreased CPU usage. Presently, we also use this code and every time when we’re  writing and submitting post then we remove code for sometime just to change the post URL before publishing and editing the tags.

 

Steps to disable WordPress Heartbeat only on Dashboard page (index.php) :

We employ the global WordPress $pagenow variable to determine which page user is presently at. we can make use of a conditional if statement to define the pages on which the WordPress Heartbeat API have to be enabled.

Add the following code at the beginning of functions.php just after this tag <?php  

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
global $pagenow;
if ( $pagenow == 'index.php' )
wp_deregister_script('heartbeat');
}

The above code disables the wordpress heartbeat interval only on WordPress dashboard page. (It only make a moderate difference in CPU usage.)

Steps to maintain WordPress Heartbeat only on post.php and post_new.php pages :

By means of selectively  use of if statements we can keep the WordPress heartbeat alive on  post.php and post_new.php pages wherein they are needed the maximum. ( This step may be maximum beneficial for most of the WordPress users.)

Add the following code at the beginning of functions.php just after this tag <?php  

add_action( 'init', 'stop_heartbeat', 1 );
function stop_heartbeat() {
global $pagenow;
if ( $pagenow != 'post.php' && $pagenow != 'post-new.php' )
wp_deregister_script('heartbeat');
}

By including the above code within the functions.php the heartbeat API would be disabled everywhere except the post.php and the post_new.php pages. This is the best choice wherein you dont want to re-enable and disable it after you are done finishing the task. But the resource usage will still be significant.

 

NOTE : For you to maximize the efficiency of the above variation of permitting Heartbeat we would endorse you to live logged in only when doing something significant. In case you aren’t using WordPress then it’d be a BEST to log off and work on different task.

So, this is the process of how to disable WordPress heartbeat API to reduce CPU utilization manually without any Plugin,

 

Steps to Disable WordPress heartbeat API with Plugin

In case you don’t want to  manually  Disable WordPress heartbeat API without coding, then there is quickest way by using a plugin known as Heartbeat Control.

WordPress Plugin Heartbeat control configuration 

Go to Heartbeat Control and install plugin it and activate it.

Then visit Settings -> Heartbeat Control and from the Override Heartbeat frequency dropdown select 60 seconds. Finally, save the settings and that is it.

 

 

Plugin Heartbeat control configuration
In case you want to set heartbeat to to work from a distinct places only – like for your post and edit pages as an example.Wordpress Plugin Heartbeat control configuration

That’s it, using a plugin known as wordpress heartbeat plugin you can Disable WordPress heartbeat API without coding

Did you like it? If sure, then do remark below.

If you run into a few troubles while the use of those codes then do comment underneath, at Share-ask.com help will always receive to individuals who ask for it!

 

 

 

 

Add Google Adsense Code to WordPress Post,Page without Plugin

Ways to Add Google Adsense Code to WordPress Post,Page without Plugin

Now in case you don’t like using the WordPress plugin, and want to do it the code way, then follow below  directions

  1. Login to your WordPress admin panel say www.xyz/wp-admin/
  2. Go to Appearance section and click theme editor
  3. Open your theme’s functions.php and paste the below  code inside this  <?php                             ?>:

Suppose you want to insert ads only inside posts but not pages  in wordpress then paste the below  code in your theme’s functions.php inside this  

<?php                             ?> :

//Insert ads after second paragraph of single post content.

add_filter( 'the_content', 'prefix_insert_post_ads' );

function prefix_insert_post_ads( $content ) {
	
	$ad_code = '<div>Ads code goes here</div>';

	if ( is_single() && ! is_admin() ) {
		return prefix_insert_after_paragraph( $ad_code, 2, $content );
	}
	
	return $content;
}
 
// Parent Function that makes the magic happen
 
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
	$closing_p = '</p>';
	$paragraphs = explode( $closing_p, $content );
	foreach ($paragraphs as $index => $paragraph) {

		if ( trim( $paragraph ) ) {
			$paragraphs[$index] .= $closing_p;
		}

		if ( $paragraph_id == $index + 1 ) {
			$paragraphs[$index] .= $insertion;
		}
	}
	
	return implode( '', $paragraphs );
}

Suppose you want to insert ads between Post,Page,attachment in wordpress then paste the below code in your theme’s functions.php

inside this  <?php                             ?>;



//Insert ads after second paragraph of Post,Page content.

add_filter( 'the_content', 'prefix_insert_post_ads' );

function prefix_insert_post_ads( $content ) {
 
 $ad_code ='<div>Ads code goes here</div>';

 if ( is_singular() && ! is_admin() ) {
 return prefix_insert_after_paragraph( $ad_code, 2, $content );
 }
 
 return $content;
}
 
// Parent Function that makes the magic happen
 
function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
 $closing_p = '</p>';
 $paragraphs = explode( $closing_p, $content );
 foreach ($paragraphs as $index => $paragraph) {

 if ( trim( $paragraph ) ) {
 $paragraphs[$index] .= $closing_p;
 }

 if ( $paragraph_id == $index + 1 ) {
 $paragraphs[$index] .= $insertion;
 }
 }
 
 return implode( '', $paragraphs );
}


Note-

where it says “Ad code goes here” simply paste your adsense code 


where it says
is_single(), which only places ads in single posts, so if you want ads
in post,page,attachment then you should use is_singular(), which test for is_single(), is_page() or is_attachment()

Trick to Display WordPress Related Posts by category,tag without Plugin

[fusion_builder_container hundred_percent=”no” equal_height_columns=”no” menu_anchor=”” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” class=”” id=”” background_color=”” background_image=”” background_position=”center center” background_repeat=”no-repeat” fade=”no” background_parallax=”none” parallax_speed=”0.3″ video_mp4=”” video_webm=”” video_ogv=”” video_url=”” video_aspect_ratio=”16:9″ video_loop=”yes” video_mute=”yes” overlay_color=”” video_preview_image=”” border_size=”” border_color=”” border_style=”solid” padding_top=”” padding_bottom=”” padding_left=”” padding_right=””][fusion_builder_row][fusion_builder_column type=”1_1″ layout=”1_1″ background_position=”left top” background_color=”” border_size=”” border_color=”” border_style=”solid” border_position=”all” spacing=”yes” background_image=”” background_repeat=”no-repeat” padding_top=”” padding_right=”” padding_bottom=”” padding_left=”” margin_top=”0px” margin_bottom=”0px” class=”” id=”” animation_type=”” animation_speed=”0.3″ animation_direction=”left” hide_on_mobile=”small-visibility,medium-visibility,large-visibility” center_content=”no” last=”no” min_height=”” hover_type=”none” link=””][fusion_text]

Display WordPress Related Posts by category without Plugin Easily

Why use WordPress without Plugin?

Display WordPress Related Posts by category,tag without Plugin

Discovering a excellent WordPress Related Posts by category plugin will  be BIG TASK. Many WordPress Related Posts by category plugin include predefined predefined styles or a rigid structure hard to integrate into your WordPress theme. Even worse, most of these WordPress plugins are tremendously database intensive and some webhosting company won’t even allow to add most “related submit” plugins on their servers (for security ,etc reasons).

How to Display WordPress Related Posts by category without Plugin?

  1. Login to your WordPress admin panel say www.xyz/wp-admin/
  2. Go to Appearance section and click theme editor
  3. Open your theme’s functions.php and paste the below  code inside this  <?php                             ?>:

Easily add the below code to your functions.php file which is located at yourwebsitename.com/wp-admin/theme-editor.php

function relatedPostsbyCategory(){
$original_post = $post;
global $post;
$categories = get_the_category($post->ID);
if ($categories) {
$category_ids = array();
foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
$args=array(
‘category__in’ => $category_ids,
‘post__not_in’ => array($post->ID),
‘posts_per_page’=> 2, // Number of related posts that will be shown.
‘caller_get_posts’=>1
);
$my_query = new wp_query( $args );
if( $my_query->have_posts() ) {
echo ‘<div id=”related_posts”><h3>Related Posts</h3><ul>’;
while( $my_query->have_posts() ) {
$my_query->the_post(); ?>
<li><div class=“relatedthumb”><a href=<? the_permalink()?> rel=“bookmark” title=<?php the_title(); ?>><?php the_post_thumbnail(); ?></a></div>
<div class=“relatedcontent”>
<h3><a href=<? the_permalink(); ?> rel=“bookmark” title=<?php the_title(); ?>><?php the_title(); ?></a></h3>
<?php the_time(‘M j, Y’); ?>
</div>
</li>
<?php
}
echo ‘</ul></div>’;
}
}
$post = $original_post;
wp_reset_query();
}
Note-
If you want to increase number of Related Posts per page ,then in above code just change number ‘posts_per_page’
Now to Display WordPress Related Posts at the end of the article you will need to put below code any where in single.php
<?php relatedPostsbyCategory();?>

Below is the example where in www.Share-ask.com web site we have placed  code   in single.php file to display Related Post  <?php relatedPostsbyCategory();?> at the end of the article

<div class=”thecontent”>
<?php the_content(); ?>
<?php relatedPostsbyCategory();?></div>
How to Display WordPress Related Posts by tag without Plugin?

Easily add the below code to your functions.php file which is located at yourwebsitename.com/wp-admin/theme-editor.php

functionjoints_related_posts() {
    global$post;
    $tags= wp_get_post_tags( $post->ID );
    if($tags) {
        foreach( $tagsas$tag) {
            $tag_arr.= $tag->slug . ',';
        }
        $args= array(
            'tag'=> $tag_arr,
            'numberposts'=> 3, /* You can change this to show more */
            'post__not_in'=> array($post->ID)
        );
        $related_posts= get_posts( $args);
        if($related_posts) {
        echo'<h4>Related Posts</h4>';
        echo'<ul id="joints-related-posts">';
            foreach( $related_postsas$post) : setup_postdata( $post); ?>
                <li class="related_post">
                    <a class="entry-unrelated"href="<?php the_permalink() ?>"title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
                    <?php get_template_part( 'partials/content', 'byline'); ?>
                </li>
            <?php endforeach; }
            }
    wp_reset_postdata();
    echo'</ul>';
}
Note-
If you want to increase number of Related posts per page,then in above code just change number in ‘numberposts’ 
This code will not display  related posts if no related posts are found.
Now to Display WordPress Related Posts at the end of the article you will need to put below code any where in single.php –
<?php joints_related_posts();?>

Below is the example where in www.Share-ask.com web site we have placed  code   in single.php file to display Related Post  <?php joints_related_posts();?> at the end of the article

<div class=”thecontent”>
<?php the_content(); ?>
<?php joints_related_posts();?></div>
If you are gettng any error  PM me to chat-besumitbe@gmail.com/skype-bpshbp today

[/fusion_text][/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]