Custom Pagination in wp

Add custom pagination in wordpress

pagination
Continue reading “Custom Pagination in wp”

Advertisements

Get Id By Slug Or Slug By Id WP

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

On Page Scroll Floating Form

floatingform

Continue reading “Floating Form Or Menu”

Create Short Code with Multiple attributes

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 “Create Short Code with Multiple attributes”

Add Category or Tags For Pages

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 “Add Category or Tags For Pages”

Get Specific Class name start with something

Get all classes that start with btn:



<ul>
<li class="etape btn-one others"></li>
<li class="etape btn-two others"></li>
<li class="etape btn-three others"></li>
</ul>

Continue reading “Get Specific Class name start with something”

Change Navigation Active on Page Scroll

My Navigation

<header>
	<nav>
		<ul>
			<li><a class="active" href="#home">Home</a></li>
			<li><a href="#about">About</a></li>
			<li><a href="#services">Services</a></li>
			<li><a href="#contact">Contact</a></li>
		</ul>
	</nav>
</header>

Continue reading “Change Navigation Active on Page Scroll”