コード例 #1
0
ファイル: content.php プロジェクト: pwsclau/kurastar_dev
        ?>
			              	<li>
							  <a href="<?php 
        echo get_permalink();
        ?>
" class="post-list-thumb-wrap">
			                    <?php 
        //Returns All Term Items for "my_taxonomy"
        $category = wp_get_post_terms($post->ID, 'article_cat', array("fields" => "names"));
        $countries = wp_get_post_terms($post->ID, 'article_country_cat', array("fields" => "names"));
        $authorID = get_the_author_meta($post->ID);
        $curator_profile = get_cupp_meta($authorID, 'thumbnail');
        $custom_image_link = get_post_meta($post->ID, '_custom_image_link', true);
        ?>
			                  		<div class="postimg" style="background: url(<?php 
        echo getArticleImage($post->ID);
        ?>
)"></div>
				                </a>
				                <div class="labels">
				                	<?php 
        if ($countries) {
            ?>
				                		<?php 
            foreach ($countries as $country) {
                ?>
				                			<a href="<?php 
                echo '/search-results/?country=' . $country . '&category=select+category&post_type=post+type+curators-cat';
                ?>
" class="countrylabel">
				                				<i class="fa fa-map-marker"></i> 
コード例 #2
0
ファイル: functions.php プロジェクト: pwsclau/kurastar_dev
function custom_search_ajax_request()
{
    global $wpdb;
    $sql = "";
    $sql2 = "";
    $condition = "";
    $orderby = "";
    $orderb2 = "";
    $sql = "SELECT p.* \n          FROM {$wpdb->prefix}posts p\n          INNER JOIN {$wpdb->prefix}term_relationships ON ( p.ID = {$wpdb->prefix}term_relationships.object_id ) \n          INNER JOIN {$wpdb->prefix}term_taxonomy ON ( {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id ) \n          INNER JOIN {$wpdb->prefix}terms ON ( {$wpdb->prefix}term_taxonomy.term_id = {$wpdb->prefix}terms.term_id ) \n          WHERE p.post_type =  'acme_article' ";
    $sql2 = "SELECT p.*\n          FROM {$wpdb->prefix}posts p\n          INNER JOIN {$wpdb->prefix}term_relationships ON ( p.ID = {$wpdb->prefix}term_relationships.object_id ) \n          INNER JOIN {$wpdb->prefix}term_taxonomy ON ( {$wpdb->prefix}term_relationships.term_taxonomy_id = {$wpdb->prefix}term_taxonomy.term_taxonomy_id ) \n          INNER JOIN {$wpdb->prefix}terms ON ( {$wpdb->prefix}term_taxonomy.term_id = {$wpdb->prefix}terms.term_id ) \n          WHERE p.post_type = 'acme_article' ";
    if ($_SESSION['search_data']['title'] != '') {
        // $condition .="AND p.post_title LIKE '".$_SESSION['search_data']['title']."'% ";
        $condition .= ' AND p.post_title LIKE \'%' . esc_sql(like_escape($_SESSION['search_data']['title'])) . '%\' ';
    } else {
        if ($_SESSION['search_data']['country'] != '' && $_SESSION['search_data']['category'] == '') {
            $condition .= "AND {$wpdb->prefix}terms.name =  '" . $_SESSION['search_data']['country'] . "'\n\t          AND {$wpdb->prefix}term_taxonomy.taxonomy =  'article_country_cat' ";
        } elseif ($_SESSION['search_data']['country'] == '' && $_SESSION['search_data']['category'] != '') {
            $condition .= "AND {$wpdb->prefix}terms.name =  '" . $_SESSION['search_data']['category'] . "'\n          AND {$wpdb->prefix}term_taxonomy.taxonomy =  'article_cat' ";
        } elseif ($_SESSION['search_data']['country'] != '' && $_SESSION['search_data']['category'] != '') {
            $condition .= "AND {$wpdb->prefix}terms.name =  '" . $_SESSION['search_data']['country'] . "'\n          AND {$wpdb->prefix}term_taxonomy.taxonomy =  'article_country_cat' ";
            $condition .= "AND {$wpdb->prefix}terms.name =  '" . $_SESSION['search_data']['category'] . "'\n          AND {$wpdb->prefix}term_taxonomy.taxonomy =  'article_cat' ";
        }
    }
    $orderby = "AND p.post_status = 'publish'\n\t    \t  GROUP BY p.ID\n\t          ORDER BY p.post_date DESC\n\t          LIMIT {$_POST['paged']}, " . CUSTOM_POST_PER_PAGE . "";
    $orderby2 = "AND p.post_status = 'publish'\n\t    \t  GROUP BY p.ID\n\t          ORDER BY p.post_date DESC";
    $sss = '';
    $sss2 = '';
    if ($_SESSION['search_data']['country'] == '' && $_SESSION['search_data']['category'] == '' && $_SESSION['search_data']['title'] == '') {
        $results = $wpdb->get_results($sql . $orderby);
        $temp_res = $wpdb->get_results($sql2 . $orderby2);
        $sss = $sql . $orderby;
        $sss2 = $sql2 . $orderby2;
    } else {
        $results = $wpdb->get_results($sql . $condition . $orderby);
        $temp_res = $wpdb->get_results($sql2 . $condition . $orderby2);
        $sss = $sql . $condition . $orderby;
        $sss2 = $sql2 . $condition . $orderby2;
    }
    $max_count = 0;
    foreach ($temp_res as $count) {
        $max_count++;
    }
    $ctr = 0;
    $html = "";
    foreach ($results as $res) {
        $category = wp_get_post_terms($res->ID, 'article_cat', array("fields" => "names"));
        $countries = wp_get_post_terms($res->ID, 'article_country_cat', array("fields" => "names"));
        $html .= '<li>';
        $html .= '<a href="' . get_permalink($res->ID) . '" class="post-list-thumb-wrap">';
        $html .= '<div class="postimg" style="background: url(' . getArticleImage($res->ID) . ')"></div>';
        $html .= '</a>';
        $html .= '<div class="labels">';
        if ($countries) {
            foreach ($countries as $country) {
                $html .= '<a href="/search-results/?country=' . $country . '&category=select+category&post_type=post+type+curators-cat" class="countrylabel">';
                $html .= '<i class="fa fa-map-marker"></i>';
                $html .= $country;
                $html .= '</a>';
            }
        }
        if ($category) {
            foreach ($category as $cat) {
                $html .= '<a href="/search-results/?country=select&category=' . $cat . '+category&post_type=post+type+curators-cat" class="countrylabel">';
                $html .= '<i class="fa fa-map-marker"></i>';
                $html .= $cat;
                $html .= '</a>';
            }
        }
        $html .= '</div>';
        $html .= '</li>';
        $ctr++;
    }
    echo json_encode(array('test' => $_SESSION, 'test2' => $sss, 'test3' => $sss2, 'paged' => $_POST['paged'], 'post_status' => 'publish', 'result' => $html, 'count' => $ctr + $_POST['paged'], 'max' => (int) $max_count));
    die;
}
コード例 #3
0
ファイル: functions.php プロジェクト: pws-edz/kurastar
function default_ajax_request()
{
    global $wp_query;
    $params = array('post_type' => $_POST['post_type'], 'posts_per_page' => $_POST['posts_per_page'], 'paged' => $_POST['paged'], 'post_status' => $_POST['status'], 'orderby' => $_POST['orderby'], 'order' => $_POST['order']);
    $ctr = 0;
    $wp_query = new WP_Query($params);
    $html = "";
    if ($wp_query->have_posts()) {
        while ($wp_query->have_posts()) {
            $wp_query->the_post();
            $category = wp_get_post_terms($post->ID, 'article_cat', array("fields" => "names"));
            $countries = wp_get_post_terms($post->ID, 'article_country_cat', array("fields" => "names"));
            $authorID = get_the_author_meta($post->ID);
            $curator_profile = get_cupp_meta($authorID, 'thumbnail');
            $custom_image_link = get_post_meta($post->ID, '_custom_image_link', true);
            $html .= '<li>';
            $html .= '<a href="' . get_permalink() . '" class="post-list-thumb-wrap">';
            $html .= '<div class="postimg" style="background: url(' . getArticleImage($post->ID) . ')"></div>';
            $html .= '</a>';
            $html .= '<div class="labels">';
            if ($countries) {
                foreach ($countries as $country) {
                    $html .= '<a href="/search-results/?country=' . $country . '&category=select+category&post_type=post+type+curators-cat" class="countrylabel">';
                    $html .= '<i class="fa fa-map-marker"></i>';
                    $html .= $country;
                    $html .= '</a>';
                }
            }
            if ($category) {
                foreach ($category as $country) {
                    $html .= '<a href="/search-results/?country=select&category=' . $category . '+category&post_type=post+type+curators-cat" class="countrylabel">';
                    $html .= '<i class="fa fa-map-marker"></i>';
                    $html .= $category;
                    $html .= '</a>';
                }
            }
            $html .= '</div>';
            $html .= '</li>';
            $ctr++;
        }
    }
    echo json_encode(array('post' => $_POST, 'paged' => $_POST['paged'], 'post_status' => $_POST['status'], 'result' => $html, 'count' => $ctr, 'max' => $wp_query->max_num_pages));
    die;
}
コード例 #4
-1
ファイル: shortcode.php プロジェクト: pwsclau/kurastar_dev
        public static function ranking_article_func()
        {
            ob_start();
            ?>

		<div class="sideboxcontent rankwrap">

			<h3 class="sidetitle">Ranking Article</h3>
			<ul class="rankarticle list-articles">

				<?php 
            $args = array('post_type' => 'acme_article', 'posts_per_page' => 5, 'meta_key' => 'post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC');
            query_posts($args);
            if (have_posts()) {
                while (have_posts()) {
                    the_post();
                    ?>
				<li>
					<a href="<?php 
                    echo get_permalink();
                    ?>
">
						<span class="rank rank1">1</span>
						<?php 
                    global $wp_query;
                    $post = $wp_query->post;
                    //var_dump($post);
                    ?>
						<div class="siderankimage"style="background-image:url(<?php 
                    echo getArticleImage($post->ID);
                    ?>
); background-position: center;"></div>
						<h4 class="ranktitle"><?php 
                    if (strlen($post->post_title) > 10) {
                        echo mb_strimwidth(the_title($before = '', $after = '', FALSE), 0, 10) . '...';
                    } else {
                        the_title();
                    }
                    ?>
</h4>
						<span class="smallpoints smallpoints-right"><?php 
                    echo get_post_views($post->ID);
                    ?>
</span>
				</li>
			<?php 
                }
            }
            wp_reset_query();
            ?>
	
			</ul>
		</div>
			
		<?php 
            return ob_get_clean();
        }