-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio.php
executable file
·152 lines (146 loc) · 4.57 KB
/
portfolio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/*
Template Name: Portfolio List Format
*/
?>
<?php get_header(); ?>
<?php $myvars = get_query_var('port_cat'); ?>
<?php
global $wpdb; // Bring our DB connection in scope
$table_name2 = "terms"; // Assign the table name we wish to query
$table_name3 = "term_taxonomy";
$table2 = $table_prefix . $table_name2; // Put it all together
$table3 = $table_prefix . $table_name3;
//echo get_query_var('cpage')."test..............";
global $wp_query;
$myarr = $wp_query->query_vars;
//print_r($myarr);
$queryresult2 = $wpdb->get_results("SELECT * FROM $table2 JOIN $table3 WHERE $table3.term_id=$table2.term_id and $table2.slug='$myvars' and $table3.taxonomy='category'");
$category_id=1;
foreach($queryresult2 as $result2){
$category_id=$result2->term_id;
}
?>
<div class="wrapper portfolio-list">
<?php
// global $wp_query;
if($category_id!='' && $category_id!=1){
$my_query = new WP_Query( array(
'paged'=> get_query_var('paged'),
'post_type'=>'portfolio',
'cat'=>$category_id
));
}
else {
$category_id=1;
$my_query = new WP_Query( array(
'post_type'=>'portfolio',
'paged'=> get_query_var('paged')
));
}
?>
<h1><?php
$cat_name = "terms"; // Assign the table name we wish to query
$cat_name1 = $table_prefix . $cat_name; // Put it all together
$query_name = $wpdb->get_results("SELECT * FROM " . $cat_name1." WHERE term_id='".$category_id."'");
foreach($query_name as $res) {
if($res->name=='Uncategorized') {
echo 'All Topics';
}
else {
echo $res->name;
}
} ?></h1>
<div class="lcol">
<?php
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
if($category_id!='' && $category_id!=1){
$port_query = new WP_Query( array(
'paged'=> $paged,
'post_type'=>'portfolio',
'cat'=>$category_id,
'post_per_page' => 8
));
}
else {
$port_query = new WP_Query(array(
'post_type' => 'portfolio',
'paged' => $paged,
'post_per_page' => 8)
);
}
if ($port_query->have_posts()): while($port_query->have_posts()): $port_query->the_post();?>
<?php
$custom = get_post_custom($post->ID);
$project_image = $custom["project_image"][0];
?>
<?php $param = get_permalink($post->ID); ?>
<div class="group">
<div class="project">
<a href="<?php the_permalink(); ?>" class="figlink" title="<?php the_title();?>">
<figure class="load">
<img src="<?=$project_image?>" />
</figure>
</a>
</div>
<div class="shadow plsdw"></div>
</div>
<?php endwhile; endif;?>
<div class="pagination">
<div class='wp-pagenavi'>
<?php wp_pagenavi( array( 'query' => $port_query ) ); ?>
</div>
</div>
</div>
<div class="rcol">
<aside class="categories">
<section>
<h3>Topics</h3>
<ul class="list">
<?php
$table_name = "term_taxonomy"; // Assign the table name we wish to query
$table = $table_prefix . $table_name; // Put it all together
$queryresult = $wpdb->get_results("SELECT * FROM " . $table." WHERE parent='0' and taxonomy='category'");
foreach($queryresult as $result) {
$table_name1 = "terms"; // Assign the table name we wish to query
$table1 = $table_prefix . $table_name1; // Put it all together
$queryresult1 = $wpdb->get_results("SELECT * FROM " . $table1." WHERE term_id='".$result->term_id."'");
foreach($queryresult1 as $result1) {
if($result1->name=='Uncategorized') {
$result1->name='all topics';
}
if($category_id=='') {
$get_catid=1;
}
else {
$get_catid=$category_id;
}
if($result1->term_id!='' && $result1->term_id!=1) {
$bb='eta te';
$my_query1 = new WP_Query( array(
'post_type'=>'portfolio',
'cat'=>$result1->term_id,
'post_status'=>'publish'
));
}
else {
$bb='ota te noy';
$my_query1 = new WP_Query( array(
'post_type'=>'portfolio',
'post_status'=>'publish'
));
}
if($my_query1->post_count>0) { ?>
<li <?php echo $result->term_id==$get_catid?'class="current"':'';?>><a href="<?php echo site_url(); ?>/portfolio/topic/<?php echo $result1->slug;?>" ><?php echo $result1->name;?> </a></li>
<?php
}
}
}
?>
</ul>
<div class="arrow slide4"> </div>
</section>
</aside>
</div>
</div>
<?php get_footer(); ?>