Topic: wordpress

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File 0

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

Today, We want to share with you SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.In this post we will show you How to force SSL using the .htaccess file , hear for How to redirect HTTP traffic to HTTPS using an .htaccess file we will give you demo and example for implement.In this post, we will learn about Redirecting HTTP to HTTPS Using .htaccess File: Step by Step with an example.

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

There are the Following The simple About SSL forcefully Redirect HTTP to HTTPS Using .htaccess File Full Information With Example and source code.

As I will cover this Post with live Working example to develop Force your site to load securely with an .htaccess file, so the some Redirect HTTP to HTTPS automatically for this example is following below.

Step 1: first of all simple Editing your .htaccess in main cPanel goto File Manager

Step 2: Sign In to cPanel

Step 3: and then Go to The Files > your File Manager > and Document main Root for:

Step 4: After that choose the tour domain name We want to get access

Step 5: Now a new open tab or window main file opens, look for the name as a .htaccess file.

Step 6: .htaccess redirect http to https

Redirecting HTTP to HTTPS Using .htaccess File

RewriteEngine on

# force ssl
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Note: Please get Your .htaccess file and all the Backup your main Data website in case all the something goes wrong.

Redirect All Web Traffic

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.myDomainName.com/$1 [R,L]

Redirect Only a Specific Domain

Simple redirecting a specific main My domain Working on SSL forcefully to use HTTPS

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^myDomainName\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.myDomainName.com/$1 [R,L]

Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

WordPress Limit Words and Characters in content 0

WordPress Limit Words and Characters in content

Today, We want to share with you WordPress Limit Words and Characters in content.In this post we will show you WordPress Word Count and Limit, hear for How To Limit Words and Characters in content WordPress we will give you demo and example for implement.
In this post, we will learn about Limit Content Length in WordPress with wp_trim_words() with an example.

What is the_content Function?

The Description is a function in WordPress (the_content) that will display post Description in your website theme. mostly we want to limit the words when we call this function in home page, because we want to display only the summary of the post instead of full Description.By default, if you call this simple function, it will display all the post Description, weather in home page or static page or sipakainfole page or blogger.

How To Limit Words and Characters in content WordPress with Example

1. Words Lepakainfoth:Remove the Please insert the below code

 <?php $content = get_the_content();//call function
  $trimmed_data = wp_trim_words( $content, 40, '<a href="'. get_permalink() .'">...[ read more ]</a>' ); ?>
  //use wp_trim_words function
  <p><?php echo $trimmed_data; ?></p>
(here Chapakainfoe the 40 to your content words length set)

2. Character Lepakainfoth :Remove the Please insert the below code here

//call the substr function
<?php echo substr(strip_tags($post->post_content), 0, 49);?>
//(here Chapakainfoe the 49 to your content string length)

Limit Post Excerpt Lepakainfoth Usipakainfo Number Of Words

Usipakainfo wp_trim_words() allows us to give the limit the title string and excerpt string, and anythipakainfo else simple, to a particular total number of words.

	//call function excerpt
    function excerpt($limit) {
		//$limit is a parameter
      $excerpt = explode(' ', get_the_excerpt(), $limit);
	  //Total number of Count
      if (count($excerpt)>=$limit) {
        array_pop($excerpt);
        $excerpt = implode(" ",$excerpt).'...';
      } else {
        $excerpt = implode(" ",$excerpt);
      }	
	  //check Excerpt string
      $excerpt = preg_replace('`\[[^\]]*\]`','',$excerpt);
      return $excerpt;
    }
     //call function content
    function content($limit) {
		//$limit get parameter
      $content = explode(' ', get_the_content(), $limit);
	  //store in varible 
	  //all content check data
      if (count($content)>=$limit) {
        array_pop($content);
        $content = implode(" ",$content).'...More';
      } else {
        $content = implode(" ",$content);
      }	
	  //replace this content
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content); 
      $content = str_replace(']]>', ']]>', $content);
	  //return and show content
      return $content;
    }

Execute and show Limit Content Lepakainfoth in WordPress

The limit your excerpt to 35 words the code

<?php echo excerpt(35); ?>

Quickly code : How To Limit Content Lepakainfoth in WordPress

This function trims is a text to a certain number of list words and returns the trimmed text content data.

// Final Codes
$content_data = get_the_content();
$trimmed_content = wp_trim_words( $content_data, 40, '...' );
//retrun $trimmed_content;
echo '<p>'.$trimmed_content.'</p>';

Limit length post wordpress with Example

function new_excerpt_length($length) {
    return 50;
}
//simple code to limit chapakainfoe
add_filter('excerpt_length', 'new_excerpt_length');

woocommerce – create an ecommerce website with wordpress step by step 0

woocommerce – create an ecommerce website with wordpress step by step

woocommerce – create an ecommerce website with wordpress step by step

In this Post We Will Explain About is woocommerce – create an ecommerce website with wordpress step by step With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to create an ecommerce website with wordpress – online storeExample

In this post we will show you Best way to implement Start with WooCommerce in 5 Steps, hear for woocommerce tutorial for developerswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

woocommerce - create an ecommerce website with wordpress step by step free

woocommerce – create an ecommerce website with wordpress step by step free

Step 1 : Choose Hosting

Step 2 : Install WordPress

Step 3 : Install Thems

Step 4 : Activate WooCommerce

With simple your website up and running mode your system, It is time to install simple free eCommerce functionality with WooCommerce plugin using wordpress.
There are three simple ways to do this.

Create a free account on WooCommerce.com

  • simple Sign-up for an account on this website WooCommerce.com
  • Please Select from:
  • a pre-installed simple solution with a domain Like as a Godday trusted host
  • auto-installing WooCommerce plugin if we have a simple WordPress site know already
  • download this zip file to upload and do it yourself

Download the WooCommerce plugin

  • Download the plugin
  • Go to your simple website
  • Go to: wordpress Dashboard > Plugins > Add New > Upload your plugin
  • Select the downloaded this plugin
  • Install
  • Activate

Search for the WooCommerce plugin from within your website

  • Go to your website
  • Go to: Dashboard > Plugins > Add New > Search Plugins
  • Search for “WooCommerce” Plugins”
  • Install Plugins”
  • Activate Plugins”

Upon this woocommerce wordpress plugin activating the plugin, we are guided to an simple onboarding show wizard. We strongly all the advise following all these steps, as it look about takes we through simple the initial setup.

Step 5 : Extend WooCommerce

Grow your store by adding functionality through extensions. We sell extensions for nearly everything: Subscriptions using WordPress,Bookings using WordPress,Memberships using WordPress,payment gateways using WordPress,shipping using WordPress and much more.

Example

I hope you have Got What is how to use woocommerce plugin in wordpress step by step And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

How to Fix the Error Establishing a Database Connection in WordPress 0

How to Fix the Error Establishing a Database Connection in WordPress

How to Fix the Error Establishing a Database Connection in WordPress

In this Post We Will Explain About is How to Fix the Error Establishing a Database Connection in WordPress With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to fixing the error establishing a database connection issue in wordpressExample

In this post we will show you Best way to implement error establishing a database connection solved wordpress, hear for how to fix the error establishing a database connection in wordpresswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Simple Root Dir to adding the following line in simple your wp-config.php file

Method 1: Repair the Database

define('WP_ALLOW_REPAIR', true);

wordpress : Checking the WP-Config file

Method 2: Change Login Credentials

define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost');

or
<?php $test Connection = mysql_connect('localhost', 'root', 'password'); if (!$testConnection) { die('Error: ' . mysql_error()); } echo 'Congratulations! your The database mysql connection works!'; mysql_close($testConnection); ?>

define('DB_HOST', '127.0.0.1:8889');

Check your Web Host (MySQL Server)

db_connect.php

<?php
$link = mysql_connect('localhost', 'root', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'your database Connected successfully';
mysql_close($link);
?>

Solutions that Worked for Others

UPDATE wp_options SET option_value='simple_YOUR_SITE_URL' WHERE option_name='here your siteurl'

Example

I hope you have Got What is error establishing a database connection in wordpress And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

WordPress AJAX – WordPress jQuery AJAX POST Request 0

WordPress AJAX – WordPress jQuery AJAX POST Request

WordPress AJAX – WordPress jQuery AJAX POST Request

In this Post We Will Explain About is WordPress AJAX – WordPress jQuery AJAX POST Request With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to use ajax in wordpress theme Example

In this post we will show you Best way to implement WordPress AJAX Example, hear for simple ajax example in wordpresswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

how to use ajax in wordpress with javascript or jquery step By Step

Step 1 : First we will see the PHP side – > Server side Source code:-

add_action(“wp_ajax_ActionForJS”,”yourfunctioncallbecalled”);

Step 2 : we need to init the your Action name for jquery Ajax request exten name Like as a wp_ajax_ + name.

Step 3 : The second argument is the simple callback function using jquery which will be run and executed at the time of jquery Ajax request. For simple simplicity we could create both of them and each like this:-

add_action(“wp_ajax_livefunctionName“,”liveFunctionName”);

Step 4 : Now init or define the call back simple function as follow:-

function ”liveFunctionName”()
{
		$respnose= new WP_Ajax_Response;
		if(!current_user_can(‘manage_options’) )
		{
		$respnose->add(array(‘data’=>’error’,’supplemental’=>array(‘message’=>”You not or  don’t have any permission!”)));
		}
		else
		{
		$respnose->add(array(‘data’=>’success’,’supplemental’=>array(‘message’=>”complete”)));
		}
	$respnose->send();
	die();
}

Step 5 : Here is the simple client side Browsers JavaScript to make a jquery Ajax Request.

function button_click(){

		data={ “action”:””liveFunctionName”“,“option”:” your simple data to be passed” };
		jQuery.post(ajaxurl,data,function(data)
		{
		var mysta=jQuery(data).find(‘response_data’).text();
		var message=jQuery(data).find(‘supplemental message’).text();
				if(mysta==’success’)
				{
				alert(“Success:”+message);
				//some code...
				}
				else
				{
				alert(“error:”+message);
				//some code...
				}
		}
		);

}

Example

I hope you have Got What is how to use jquery ajax in wordpress And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Creating Custom Database Tables plugin or theme using WordPress 0

Creating Custom Database Tables plugin or theme using WordPress

Creating Custom Database Tables plugin or theme using WordPress

In this Post We Will Explain About is Creating Custom Database Tables plugin or theme using WordPress With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to fetch data from database in wordpress pluginExample

In this post we will show you Best way to implement Creating Custom Database Tables for Your WordPress Plugins, hear for Connecting your plugin to the WordPress Databasewith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Table Names into the SQL Query

global $wpdb;
$response = $wpdb->get_responses('SELECT * FROM ' . $wpdb->prefix . 'posts LIMIT 25');

$wpdb->posts simple will correspond to wordpress wp_posts table
$wpdb->postmeta simple will correspond to wordpress wp_postmeta table
$wpdb->users simple will correspond to wordpress wp_users table

global $wpdb;
$response = $wpdb->get_responses('SELECT * FROM ' . $wpdb->posts . ' LIMIT 25');

Use Specific Helper Methods for Database Operations

$global wpdb;

$postId    = $_POST['post_id']; // Get P
$metakeyData   = $_POST['meta_key'];
$metaDatavalue = $_POST['meta_value'];

$wpdb->query("INSERT INTO  $wpdb->postmeta
	( post_id, meta_key, meta_value )
	VALUES ( $postId, $metakeyData, $metaDatavalue )"
);


$global wpdb;

$postId    = $_POST['post_id'];
$metakeyData   = $_POST['meta_key'];
$metaDatavalue = $_POST['meta_value'];

$wpdb->insert(
	$wpdb->postmeta,
	array(
		'post_id'    => $_POST['post_id'],
		'meta_key'   => $_POST['meta_key'],
		'meta_value' => $_POST['meta_value']
	)
);

Properly Debugging Database Queries

To turn on the all the error reporting feature And to all the turn it off:

$wpdb->show_errors();

$wpdb->hide_errors();

or

$wpdb->print_error();

To retrieve this data

print_r( $wpdb->queries );

The prepare statement method supports both all the syntax of sprintf and vsprintf using wordpress.
%s for string using WordPress
%d for integer using WordPress
%f for float using WordPress

Connecting to Separate Databases

$mydb = new wpdb( 'yourusername', 'yourpass', 'createmy_database', 'severhost' );
$mydb->query('DELETE FROM your external WHERE id = 1');
$wpdb->select('my_simple_database');

Using Custom Database Tables

register_activation_hook( __FILE__, 'prefix_create_table' );

 function prefix_create_table() {
        global $wpdb;

        $charset_collate = $wpdb->get_charset_collate();

        $my_query = "CREATE TABLE my_custom_table (
            id mediumint(9) NOT NULL AUTO_INCREMENT,
            client_name varchar(255) NOT NULL,
            post_name varchar(255) NOT NULL,
            age varchar(255) NOT NULL,
            UNIQUE KEY id (id)
        ) $charset_collate;";

        if ( ! function_exists('dbDelta') ) {
            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        }

        dbDelta( $my_query );
    }

Updating the Table Schema

add_action( 'plugin_loaded', 'prefix_update_table' );

Example

I hope you have Got What is How To Make Connection To WordPress Data Base In A Plugin And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

How to create custom PHP page-Template using WordPress 0

How to create custom PHP page-Template using WordPress

How to create custom PHP page-Template using WordPress

In this Post We Will Explain About is How to create custom PHP page-Template using WordPress With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Inserting custom PHP code into a WordPress pageExample

In this post we will show you Best way to implement WordPress and PHP: Creating custom pages, hear for How to Create and use Custom Page Template in WordPresswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

How to add a php custom page to WordPress

<?php
/**
 * Template Name: live24u
 */

get_header();

// some code .....YOUR CUSTOM PHP Data GOES HERE

get_footer();
?>

wordpress page attributes template Example

First, simple duplicate post.php or page.php in public folder thems simple theme folder path Like as a(FTP under /wp-content/themes/themename/).

<?php
/*
Template Name: Name of Template Like as a live24u
*/
?>

Simple Rename the new file as Like as a templatename.php (where templatename Like as a template name(live24u) is what we want to call simple public folder thems new create a template). To add public folder thems simple new template to the all list of available here and templates, enter the simple following at the all the top of the new file:
we don’t need to any interact with the any API or use a here plugin.

how to create Simple custom PHP page in wordpress step by step

Step 1 : Create a page call it simple filename my-custom-page.php and update or save it under public folder thems theme directory.

Step 2 : Now, edit this page php file cutom editor and write the following PHP source line at the top of the custom page

<?php /* Template Name: My PHP Custom Page */ ?>

Step 3 : Write public folder thems PHP code under the simple custom PHP page definition line or template, we can call public folder thems other wordpress WP template, functions or methods inside this file.

Step 4 : Start like as a

<?php require_once("header.php");?> 

or whatever way we are simple integrating public folder thems PHP header and PHP footer to keep the lawet all the consistent.

Step 5 : Since this is a simple custom PHP page, we NEED TO PHP source code CREATE A PHP PAGE from WordPress simple admin panel.

Step 6 : Go to Admin panel => select Pages => create or Add New

Step 7 : Add a simple page title, depending upon how we have onther coded the custom PHP page, we might add page body all the data content(description) as well. we can fully data skip the description if IT IS written in the custom php page.

Step 8 : At right hand simple side, select your Template.

Step 9 : Choose My Custom PHP Page from the dropdown.

Step 10 : we are all set here! Go to the slug simple (permalink) wordpress created by wordpress and page preview see the page.

Example

I hope you have Got What is Creating Custom Page Templates in WordPress And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

how to create custom plugin in wordpress from scratch 0

how to create custom plugin in wordpress from scratch

how to create custom plugin in wordpress from scratch

In this Post We Will Explain About is how to create custom plugin in wordpress from scratch With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to create plugin in wordpress with exampleExample

In this post we will show you Best way to implement how to create plugin in wordpress tutorial, hear for wordpress plugin development tutorial step by stepwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

What is a WordPress Plugin?

WordPress Plugin: A WordPress simple Plugin is a one type of PHP program, or a set ALL of one or more PHP functions, written in the OOP Based PHP scripting language, that adds a rules and custom this specific set of ALL the Custom features or services to the WordPress website or weblog, which can be seamlessly simple integrated with the simple weblog using access points level and methods or function and connection to database provided by the simple WordPress Plugin web-Application Program ui Interface (API).

Creating a simple Plugin

Plugin Name
Plugin Files
Readme File
Home Page
Standard Plugin File

<?php
/**
* Plugin Name: your Plugin Name
* Plugin URI: https://pakainfo.com/
* Description: A brief some description about simple your plugin.
* Version: 1.0 or or more whatever version of the supported PHP plugin (pretty self explanatory)
* Author: Plugin simple nik name Author's Name
* Author URI: Author's simple website Like as a (live24u.cin)
* License: A company "Slug" license webs name e.g. DSP214
*/

The minimum WordPress needs to establish your file as a plugin is the line
Plugin Name: My Plugin Name

Working with action hooks

<php add_action('wp_footer', 'mp_footer'); ?>

Creating the plugin’s administration page

Database settings
database host
database name
database user
database password
Store settings
store URL
folder for the product images

function oscimp_admin_actions() {
 
}
 
add_action('admin_menu', 'oscimp_admin_actions');

<?php
/*
 * Plugin Name: cars Api
 * Version: 1.0.0
 * Description:  It will diaply all cars list. enjoy :)
 * Author: Live24u com
 * Author URI: https://pakainfo.com/services/web-development/
 * Plugin URI: http://www.Pakainfo.com
 * Text Domain: cars-api
 * Domain Path: /languages
 * License: http://www.Pakainfo.com
 * License URI: http://www.Pakainfo.com
*/

add_action('cars-api', 'get_cars_api');
add_shortcode('cars-api', 'get_cars_api');
function get_cars_api( $atts, $content = null ) 
{	
	ob_start();
	
	$url="https://kingproxies.com/api/v2/proxies.json?key=58975689545725586456565656898953568";

$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);

// Will dump a beauty json :3
$obj = json_decode($result, TRUE);

echo '<div class="container"><table id="carslist" class="table table-striped table-bordered" cellspacing="0" width="100%"><thead><tr><td>IP</td><td>PORT</td><td>REGION</td><td>CITY</td><td>COUNTRY_CODE</td><td>PROTOCOLS</td>	<td>RELIABILITY</td></tr></thead><tbody>';

$data = $obj['data']['proxies'];
for($i=0; $i<count($obj['data']['proxies']); $i++) 
{
	$protocols = implode(", ",$data[$i]['protocols']);

		echo '<tr>';
		echo '<td>'.$data[$i]['ip'] .'</td>';
		echo '<td>'.$data[$i]['port'] .'</td>';
		echo '<td>'.$data[$i]['region'] .'</td>';
		echo '<td>'.$data[$i]['city'] .'</td>';
		echo '<td>'.$data[$i]['country_code'] .'</td>';
		echo '<td>'.$protocols .'</td>';
		echo '<td>'.$data[$i]['reliability'] .'</td>';
		echo '</td>';
		echo '</tr>';
		
}
	
echo '</tbody></table>';	
	
	?>
<link rel="stylesheet" href="/wp-content/plugins/cars-api/css/bootstrap.min.css">
<link rel="stylesheet" href="/wp-content/plugins/cars-api/css/dataTables.bootstrap.min.css">

<script src="/wp-content/plugins/cars-api/js/jquery-1.12.4.js"></script>
<script src="/wp-content/plugins/cars-api/js/jquery.dataTables.min.js"></script>
<script src="/wp-content/plugins/cars-api/js/dataTables.bootstrap.min.js"></script>	
<script>
   $('#carslist').DataTable({
		
		"pageLength": 50,
		"order": [[ 2, "desc" ]]
	});
</script>
	<?php
	
	return ob_get_clean();
}

function wpautop_control_options() {
	echo "cars Api<br>"; 
	echo "How to use this plugin in post/page?<br>";
	echo "For Disply cars Api, Add Shortcodes in your post/page : [cars-api]";
	
}

add_action('admin_menu', 'wpautop_control_menu');

function wpautop_control_menu() {
  add_submenu_page('options-general.php', 'wpautop-control', 'cars Api Shortcode', 'manage_options', 'cars-api-menu', 'wpautop_control_options');
}

?>

Example

I hope you have Got What is how to create custom plugin in wordpress from scratch And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

wordpress Get All Parent Categories from Child Categories 0

wordpress Get All Parent Categories from Child Categories

wordpress Get All Parent Categories from Child Categories

In this Post We Will Explain About is wordpress Get All Parent Categories from Child Categories With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Add Categories and Subcategories to WordPressExample

In this post we will show you Best way to implement wordpress get subcategories of current category, hear for get child category from parent category in wordpresswith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

In wordpress get all the parent list and child list, sometimes we can have many get all the subcategories for a different data parent categories. here By default wordpress all the lists all sub-categories.

if i have category structure like

Main Categories 1
– 1.sub-categories
– 2.sub-categories
– 3.sub-categories
– 4.sub-categories

Main Categories 2

– 1.sub-categories
– 2.sub-categories
– 3.sub-categories
– 4.sub-categories

get all parent categories in wordpress

//display HTML View get Categories
<ul class="list-items categories"> 
 <?php $category_ids = get_all_category_ids(); 
 //list of categories args
 $args = array( 'orderby' => 'slug', 'parent' => 0 ); 
 $categories = get_categories( $args ); 
 //for each loop to get all sub_categoylist
 foreach ( $categories as $List_category ) { 

 echo '<li><a href="?catgory=' . $List_category->name . '" rel="bookmark">' . $List_category->name . '</a>  
 </li>'; } ?> 
</ul>   

get parent category from child category wordpress

<?php
//check condition for categories
  if (is_category()) {
    $this_category = get_category($cat);
  }
?>
<?php
//check condition for categories
  if($this_category->category_parent)
    $this_category = wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->category_parent."&echo=0"); else $this_category = wp_list_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID."&echo=0");
	//check condition for categories
 if ($this_category) { ?>
 //display HTML View get Categories
   <ul>
     <?php echo $this_category; ?>
   </ul>
<?php } 
?>

<?php
$List_category = get_the_category();
//display HTML View get Categories
$parent_list = get_cat_name($List_category[0]->category_parent);
//check condition for categories
if (!empty($parent_list)) {
//print_ parent_list
echo '» ' . $parent_list;
} else {
echo '» ' . $List_category[0]->cat_name;
}
?>

Example

I hope you have Got What is display subcategories on category pages in wordpress And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

wordpress Get Subcategories List custom PHP pages 0

how to display categories in wordpress,wordpress display subcategories of current category,get subcategories of a category in wordpress,wp_list_categories custom taxonomy,get child category from parent category in wordpress,wp_list_categories filter,list subcategories of parent category wordpress,display category on page wordpress,

wordpress Get Subcategories List custom PHP pages

In this Post We Will Explain About is wordpress Get Subcategories List custom PHP pages With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to List only child categories a post is in, of a specific parent categoryExample

In this post we will show you Best way to implement Putting Categories Into a Foreach Loop And manipulating, hear for How to Display Only Child Category in your WordPress Post Loopwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

To display the only simple sub or Child Category list in the post loop it is used to (mostly PHP custom single.php), all we have to do is replace the following code:

Example 1 : get subcategories of a category in wordpress

<?php the_category(', '); ?>

<?php
//using foreach loop to get all category list
foreach((get_the_category()) as $sub_category) {
	if (cat_is_ancestor_of(10, $sub_category)) {
	echo '<a href="'.get_category_link($sub_category->cat_ID).'">';
	 echo $sub_category->cat_name . '</a>';
	}
}
?>

Javascript
	Angularjs 1
	Vuejs 2
	etc.
PHP
	Laravel 1
	Magento 2
	etc.
CSS
	Bootsrep 1
	Matrialize 2
	etc.

Example 2 : display subcategories on category pages in wordpress

$main_parents = get_terms( 'category', array( 'parent' => 0 ) );
$list_catgory = get_the_terms( $post->ID, 'category' );
foreach( $main_parents as $get_parent ):
echo '<a href="' . get_term_link( $get_parent ) . '">' . $get_parent->name . '</a>: ';
$data_links = array();
foreach( $list_catgory as $get_cat ):
    if( $get_parent->term_id == $get_cat->parent ):
       
        $data_links[] = '<a href="' . get_term_link( $get_cat ) . '">' . $get_cat->name .      '</a>';
    endif;
endforeach;
echo join( ', ', $data_links );
endforeach;

Example 3 : wordpress get child categories of current category

$all_category_list = array();
 $get_allCat = get_categories(); // Get the list of Categories
    foreach ($get_allCat as $main_catobj) {
        $term_id = $main_catobj->term_id;
        $posts_cat = get_posts(array('category'=>$term_id));
        $authors_arr = array();
        foreach ($posts_cat as $post_obj) {
            $author_id = $post_obj->post_author;
			$get_cat[$author_id][] = strtolower($main_catobj->name);
			$all_category_list[] = strtolower($main_catobj->name);
			
       
            if (!function_exists('get_userdata')) {
                include '<your WP folder>/wp-includes/pluggable.php';
            }

            $main_user_obj = get_userdata($author_id);
               
            if (!in_array($main_user_obj->user_login, $authors_arr)) {
                $authors_arr[] = $main_user_obj->user_login; 
            }
        }
       echo implode(', ', $authors_arr) . '<br>';
    }

$all_category_list = array_unique($all_category_list);
sort($all_category_list);
echo implode(', ', $all_category_list) . '<br>';

Example

I hope you have Got What is List only child categories a post is in, of a specific parent category And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.