Custom Pagination in wp

Tags

,

Add custom pagination in wordpress

pagination
Continue reading

Get Id By Slug Or Slug By Id WP

Tags

, , , ,

get id by using slug

paste this function in function.php

function get_id_by_slug($page_slug) {
	$page = get_page_by_path($page_slug);
	if ($page) {
		return $page;
	} else {
		return null;
	}
}

example:
get_id_by_slug(‘about-us’);

get slug by id

global $post;
$slug = get_post( $post )->post_name;
echo $slug;

Floating Form Or Menu

Tags

, , , ,

On Page Scroll Floating Form

floatingform

*: for easing effect you need jquery easing
https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js

Detail:

  • data-skipheader: if you want to show form after user scroll header or banner section add class name here
  • data-easing: add easing name here to implement easing effect *

Continue reading

Create Short Code with Multiple attributes

Tags

,

We are going to add short code and create some of its attribute

We want to call post data on different pages with different categories and number of posts to show
also we can set post type

add this code in function.php


// This is a function for shortcode 
function custom_shortcode() {
     return 'hi i am short code function';
}

add_shortcode( 'shortcode', 'custom_shortcode' );

call this by using [shortcode]

Continue reading

Add Category or Tags For Pages

Tags

, , ,

We have function that adds an already registered taxonomy to a custom object type.
Suppose we need to add the same categories and tags we use with posts to our Pages.

Here’s how we do it:

register_taxonomy_for_object_type( 'category', 'post' );
register_taxonomy_for_object_type( 'post_tag', 'post' );

Continue reading