Skip to content

Instantly share code, notes, and snippets.

View aslamhindko's full-sized avatar

Aslam Hindko aslamhindko

View GitHub Profile
@aslamhindko
aslamhindko / post-type-loop.php
Last active March 6, 2021 20:52
Post Type Loop
<div class="testimonial">
<?php
$q = new WP_Query(
array('post_type' => array('testimonials'),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => $sitem,
'service-category' => $category)
);
@aslamhindko
aslamhindko / wp-registerpostype.php
Last active July 11, 2016 15:08
Register For Post Type
(ye post type ki registertation hain)
<?php /**
* Registers a new post type
* @uses $wp_post_types Inserts new post type object into the list
*
* @param string Post type key, must not exceed 20 characters
* @param array|string See optional args description above.
* @return object|WP_Error the registered post type object, or an error object
*/
function slider() {
<?php $my_query = new WP_Query('page_id=13');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; ?>
<div class="container blogframe">
<div class="row">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$q = new WP_Query(
array(
'post_type' => array('post'),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'ASC',
(blog post k singal.php ka loop hain)
<div class="margin100"></div>
<div class="container">
<div class="row">
<?php /* The loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="col-md-8 col-sm-8">
<article class="posting">
<?php
if(has_post_thumbnail()){
function pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
.pagination {clear:both;padding:20px 0;position:relative;font-size:11px;line-height:13px;}
.pagination span, .pagination a {display: block;float: left;margin: 2px 2px 2px 0;padding: 11px 17px 11px 17px;text-decoration: none;width: auto;color: #fff;background: #555;font-size: 18px;}
.pagination a:hover{color:#fff;background: #AA3F94;}
.pagination .current {padding: 11px 17px 11px 17px;background: #AA3F94;color: #fff;font-size: 18px;}
(agar loop main BG image ho tu ye loop use kare ge = loop ka akari main background ki css rakhe ge)
<?php $my_query = new WP_Query('page_id=45');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
if(has_post_thumbnail()){
$thumbnailaaa = wp_get_attachment_image_src(get_post_thumbnail_id(),'full', true);
}
?>
(ye wordpress loop counter hain agar meri post type multiple ho tu use hogi)
<div class="container">
<div class="row">
<div class="col-md-12">
<?php
$q = new WP_Query(
array('post_type' => array('product'),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'ASC',
agat wordpress main har page per alag header image leni ho tu is k liye code dege
<?php $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(),'full', true); ?>
<section class="treatmentpage" style="background: url(<?php echo $thumbnail[0]; ?>) no-repeat;">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1><?php the_title(); ?></h1>
<ol class="breadcrumb">