Ejemplo n.º 1
0
function pbl_year_filter_dropdown($pub, $category)
{
    global $wp_query;
    $year = isset($wp_query->query['year']) ? $wp_query->query['year'] : date('Y');
    ?>
    <select id="QuRepYear" name="QuRepYear"><?php 
    global $wpdb;
    $term_id = get_term_by('slug', $pub, 'pubcode')->term_id;
    $category_id = get_category_by_slug($category)->term_id;
    $datePosts = $wpdb->get_results($wpdb->prepare("\r\n                    SELECT DISTINCT YEAR( {$wpdb->posts}.post_date ) AS year\r\n                        FROM wp_term_relationships\r\n                        INNER JOIN wp_term_relationships as wptr ON wp_term_relationships.object_id=wptr.object_id and wp_term_relationships.term_taxonomy_id <> wptr.term_taxonomy_id\r\n                        inner join wp_posts on wp_posts.ID = wp_term_relationships.object_id\r\n                        inner join wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id  = wp_term_relationships.term_taxonomy_id\r\n                        inner join wp_term_taxonomy as wptt on wptt.term_taxonomy_id  = wptr.term_taxonomy_id\r\n                        where (wp_term_taxonomy.term_id = %s and wp_term_taxonomy.taxonomy = 'category')\r\n                            and (wptt.term_id = %s and wptt.taxonomy = 'pubcode')\r\n                            and (wp_posts.post_status = 'publish')\r\n                            ORDER BY year DESC\r\n                ", $category_id, $term_id));
    foreach ($datePosts as $datePost) {
        ?>
        <option <?php 
        echo $datePost->year == $year ? 'selected="selected"' : '';
        ?>
 value="<?php 
        echo $datePost->year;
        ?>
"><?php 
        echo $datePost->year;
        ?>
</option>
    <?php 
    }
    ?>
</select><?php 
}
 private function get_data()
 {
     $arguments = array('hide_empty' => false);
     $uncategorized = get_category_by_slug('uncategorized');
     if ($uncategorized) {
         $arguments['category__not_in'] = array($uncategorized->term_id);
     }
     $playboard = array('series' => array(), 'total_all' => 0, 'total ninety' => 0, 'total_thirty' => 0, 'total_seven' => 0);
     /*
     	name, slug, count
     */
     $categories = get_categories();
     $total = 0;
     foreach ($categories as $category) {
         $data = array('name' => $category->name, 'slug' => strtoupper($category->slug), 'count' => $category->category_count);
         $playboard['series'][] = $data;
         $total += $category->category_count;
     }
     $playboard['total_all'] = $total;
     $playboard['total_ninety'] = $this->get_range_total(90);
     $playboard['total_thirty'] = $this->get_range_total(30);
     $playboard['total_seven'] = $this->get_range_total(7);
     $playboard['last_update'] = time();
     return $playboard;
 }
Ejemplo n.º 3
0
function company_table($side)
{
    if ($side == 'right') {
        $side = 'right_company';
    }
    if ($side == 'left') {
        $side = 'left_company';
    }
    $company_id = get_category_by_slug($side)->term_id;
    query_posts('cat=' . $company_id);
    if (have_posts()) {
        while (have_posts()) {
            the_post();
            global $post;
            $output_home_promos = "";
            $output_home_promos .= "<li class='line'>";
            $output_home_promos .= '<a id="company">';
            $output_home_promos .= "<span class='heading'>" . $post->post_title . "</span>";
            $output_home_promos .= "<span class='summary'>" . $post->post_content . "</span>";
            $output_home_promos .= "</a>";
            $output_home_promos .= "</li>";
            if (!empty($output_home_promos)) {
                $output_home_promos = "<ul class='large'>" . $output_home_promos . "</ul>";
            }
            echo $output_home_promos;
        }
    }
}
Ejemplo n.º 4
0
	/**
	 * Validate get_category_by_slug function
	 */
	function test_get_category_by_slug() {

		// create Test Categories
		$testcat = $this->factory->category->create_and_get(
			array(
				'slug' => 'testcat',
				'name' => 'Test Category 1'
			)
		);
		$testcat2 = $this->factory->category->create_and_get(
			array(
				'slug' => 'testcat2',
				'name' => 'Test Category 2'
			)
		);

		// validate category is returned by slug
		$ret_testcat = get_category_by_slug( 'testcat' );
		$this->assertEquals( $testcat->term_id, $ret_testcat->term_id );
		$ret_testcat = get_category_by_slug( 'TeStCaT' );
		$this->assertEquals( $testcat->term_id, $ret_testcat->term_id );

		// validate unknown category returns false
		$this->assertFalse( get_category_by_slug( 'testcat3' ) );

	}
 static function search_handler()
 {
     if (strtok($_SERVER["REQUEST_URI"], '?') == '/search') {
         load_template(plugin_dir_path(__FILE__) . 'page-search.php');
         exit;
     }
     if (strtok($_SERVER["REQUEST_URI"], '?') == '/search-request') {
         $search_options = array('s' => $_GET['s'], 'post_type' => 'post');
         if ($_GET['cat']) {
             $search_options['cat'] = get_category_by_slug($_GET['cat'])->term_id;
         }
         if ($_GET['author']) {
             $search_options['author_name'] = $_GET['author'];
         }
         $search_options['paged'] = $_GET['page'] ? $_GET['page'] : 1;
         $search_options['posts_per_page'] = 3;
         $searched_posts = new WP_Query($search_options);
         $show_more_link = $searched_posts->max_num_pages > $search_options['paged'];
         if ($search_options['paged'] > 1) {
             include 'search-more.php';
         } else {
             include 'search.php';
         }
         exit;
     }
 }
Ejemplo n.º 6
0
function get_gallery_post()
{
    if (isset($_POST['id']) && !empty($_POST['id'])) {
        $projectsCats = array('cocheras', 'terrazas', 'habitaciones', 'antes-despues');
        $id = $_POST['id'];
        $post = get_post($id);
        $gallery = get_post_gallery($post->ID, false);
        $category = get_the_category($post->ID);
        $cat_elements = array();
        $cat_info = array();
        foreach ($projectsCats as $cat) {
            $catdata = get_category_by_slug($cat);
            $args = array('category_name' => $cat, 'orderby' => 'meta_value_num', 'meta_key' => 'order', 'order' => 'ASC', 'posts_per_page' => 3);
            $projects = new WP_Query($args);
            array_push($cat_info, $catdata);
            array_push($cat_elements, $projects);
        }
        if ($gallery !== false) {
            $gallerydata = array();
            $images = explode(',', $gallery['ids']);
            foreach ($images as $key => $image) {
                $imagedata = wp_prepare_attachment_for_js($image);
                array_push($gallerydata, $imagedata);
            }
            $post_info = array('post' => $post, 'category' => $category, 'categories' => $cat_elements, 'cat_info' => $cat_info, 'gallery' => $gallerydata);
            echo json_encode($post_info);
        }
        die;
    } else {
        echo 'error';
        die;
    }
    die;
}
Ejemplo n.º 7
0
function echoSidebar($category)
{
    $title = get_category_by_slug($category);
    echo "<div id='sidebar'>\n\t<div id='text-block'>\n\t\t<div class='top-shadow'>\n\t\t\t<h4>";
    echo $title->name;
    echo " </h4>\n\t\t</div>\n\t\t<div class='center'>\n\t\t\t<div class='text-entry'>\n\t\t\t\t<p>";
    _e('Более детальная информация:', 'dpm');
    echo "</p>\n\t\t\t\t<ul>\n\t\t\t\t";
    $the_query = new WP_Query(array('category_name' => $category));
    while ($the_query->have_posts()) {
        $the_query->the_post();
        echo '<li>
			<a class="news-head" href="';
        the_permalink();
        echo '">';
        the_title();
        echo '</a>
			</li>';
    }
    echo '</ul>
			</div>
		<div class="bottom-shadow">
	   </div>
 </div>
</div>';
}
Ejemplo n.º 8
0
function loop_category($category)
{
    $idObj = get_category_by_slug($category);
    $cat_name = $idObj->name;
    if ($category === 'news') {
        $number = 4;
    } else {
        $number = 1;
    }
    $args = array('posts_per_page' => $number, 'category_name' => $category);
    $posts_array = get_posts($args);
    $length = count($posts_array);
    if ($length > 0) {
        echo '<a href="' . get_category_link($idObj->cat_ID) . ' " ><h3 class="big-article-title">' . $cat_name . '</h3></a>';
        global $post;
        foreach ($posts_array as $key => $post) {
            setup_postdata($post);
            if ($key === 0) {
                get_template_part('templates/content', get_post_type() != 'post' ? get_post_type() : get_post_format());
            } else {
                if ($key === 1) {
                    echo '<ul class="other-post-list length' . ($length - 1) . '">';
                }
                get_template_part('templates/content', 'post-intro');
                if ($key === $length) {
                    echo '</ul>';
                }
            }
        }
        wp_reset_postdata();
    }
}
function asa_inne_ute_widget($args)
{
    // extract the arg passed by theme
    extract($args);
    // get option (picture url)
    $options = get_option("asa_inne_ute_picture_url_widget");
    //get latest inne-ute
    $myposts = get_posts('numberposts=1&category=' . get_category_by_slug('inne-utelistan')->term_id . '&order=DESC&orderby=date');
    // get the latest list
    foreach ($myposts as $inne_post) {
        $latest_inne_ute = $inne_post->guid;
    }
    // not sure if we need theese extracted args but it is said to be good for compability
    // widget layout with img scr url set by options.
    ?>

<div class="r_side">
  <div id="inneutelista">
    <a title="Inne- och utelistan" href="<?php 
    echo $latest_inne_ute;
    ?>
">
    <img alt="Till Åsas kungliga inne- och utelista" src="<?php 
    echo $options['asa_inne_ute_picture_url'];
    ?>
" title="Till Åsas kungliga inne- och utelista"/></a>
  </div>
</div>

<?php 
}
Ejemplo n.º 10
0
    public function widget($args, $instance)
    {
        $post_cat = $instance['post_cat'];
        $post_num = $instance['post_num'];
        $post_slug = get_category_by_slug($post_cat);
        echo $args['before_widget'];
        echo $args['before_title'];
        echo $post_slug->name;
        echo $args['after_title'];
        echo '<ul class="widget-post">';
        $widgetPost = new WP_Query(array('post_type' => 'post', 'category_name' => $post_cat, 'posts_per_page' => $post_num));
        global $post;
        if ($widgetPost->have_posts()) {
            while ($widgetPost->have_posts()) {
                $widgetPost->the_post();
                ?>
        <li class="widget-post__list">
            <a href="<?php 
                the_permalink();
                ?>
" class="clearfix">
                <div class="widget-post__thumb">
                    <?php 
                the_post_thumbnail('thumb_s', array('class' => 'thumb'));
                ?>
                </div>
                <div class="widget-post__body">
                    <h3 class="widget-post__title">
                        <?php 
                if (mb_strlen($post->post_title) > 35) {
                    $title = mb_substr($post->post_title, 0, 35);
                    echo $title . '...';
                } else {
                    echo $post->post_title;
                }
                ?>
                    </h3>
                </div>
            </a>
        </li>
        <?php 
            }
            echo '</ul>';
            ?>
        <div class="widget-post__more">
            <a href="<?php 
            echo home_url('/') . $post_cat;
            ?>
">すべて読む<i class="fa fa-chevron-circle-right"></i></a>
        </div>
        <?php 
        } else {
            ?>
        <p>投稿なし</p>
        <?php 
        }
        wp_reset_query();
        echo $args['after_widget'];
    }
Ejemplo n.º 11
0
function get_children_categories($parent_slug)
{
    $c = get_category_by_slug($parent_slug);
    if ($c) {
        $category_id = $c->term_id;
        return get_categories(array('child_of' => $category_id));
    }
}
Ejemplo n.º 12
0
function migrate_blog()
{
    /*
         * $tabRub[0] = "Annonces";
        $tabRub[1] = "Partenariat";
        $tabRub[2] = "Vie d'Anciela";
        $tabRub[3] = "Autres";
         * */
    $categories = array('annonces', 'partenariat', 'anciela', 'autres');
    $categoryNames = array('annonces' => "Annonces", 'partenariat' => 'Partenariats', 'anciela' => "Vie d'anciela", 'autres' => 'Autres');
    foreach ($categoryNames as $categorySlug => $categoryName) {
        wp_insert_term($categoryName, 'category', array('slug' => $categorySlug));
    }
    $db = mysqli_connect("localhost", "root", "", "db161162332") or die("Error " . mysqli_error($link));
    // Setup the author, slug, and title for the post
    $author_id = 1;
    $args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null);
    $attachments = get_posts($args);
    $db->query('set names utf8');
    $db->query("SET character_set_connection = 'UTF8'");
    $db->query("SET character_set_client = 'UTF8'");
    $db->query("SET character_set_results = 'UTF8'");
    $result = $db->query("select * from `anc_info_blog`");
    while ($row = $result->fetch_array()) {
        $categoryIntId = $row["rub_blog"] - 1;
        $category = $categories[$categoryIntId];
        $category = get_category_by_slug($category);
        if ($category) {
            $category = $category->term_id;
        }
        $title = stripslashes($row["titre_blog"]);
        $date = $row["date_pub_deb_blog"];
        $content = stripslashes($row['texte_blog']);
        $img = $row['image_blog'];
        $align = $row['image_pos_blog'] == 0 ? 'center' : 'right';
        if ($img) {
            foreach ($attachments as $post) {
                setup_postdata($post);
                the_title();
                $mediaTitle = $post->post_title;
                $img = explode('.', $img)[0];
                if ($mediaTitle == $img) {
                    $id = $post->ID;
                    $content = '[image id="' . $id . '" align="' . $align . '"]<br/>' . $content;
                }
                /*$dataToSave = array(
                      'ID' => $post->ID,
                      'post_title' =>
                  );
                  wp_update_post($dataToSave);*/
            }
        }
        if (null == get_page_by_title($title, null, 'post')) {
            wp_insert_post(array('comment_status' => 'open', 'ping_status' => 'closed', 'post_author' => $author_id, 'post_title' => $title, 'post_status' => 'publish', 'post_type' => 'post', 'post_category' => array($category), 'post_date' => $date . ' 12:00:00', 'post_content' => $content));
        }
    }
    mysqli_close($db);
}
Ejemplo n.º 13
0
 function category_id_from_slug($slug)
 {
     $category = get_category_by_slug($slug);
     if ($category) {
         return $category->term_id;
     } else {
         return null;
     }
 }
Ejemplo n.º 14
0
function list_type($category, $type)
{
    echo "<h1>" . get_cat_name(get_category_by_slug($category)->cat_ID) . ":</h1>\n";
    $files = new WP_Query(array('category_name' => $category, 'post_type' => $type, 'order' => 'ASC', 'orderby' => 'title'));
    while ($files->have_posts()) {
        $files->the_post();
        echo "<p>" . the_post_thumbnail() . "<strong>" . get_the_title() . "</strong>: " . get_the_content() . "</p>\n";
    }
}
Ejemplo n.º 15
0
/**
 * Remove the featured category on the home page main query
 * @param WP_Query $query
 * @since 1.2
 */
function pmc_eve_query_category($query)
{
    if ($query->is_home() && $query->is_main_query()) {
        $cat = get_category_by_slug('featured');
        if ($cat) {
            $query->set('cat', '-' . $cat->term_id);
        }
    }
}
Ejemplo n.º 16
0
function get_page_list()
{
    $cat = $_GET['cat'];
    $page = $_GET['page'];
    $posts_per_page = $_GET['posts_per_page'];
    if (!is_null($cat) && $cat != 0 && !is_null($page)) {
        $args = array("category__in" => array($cat), "paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc');
    } else {
        if (!is_null($cat) && $cat != 0 && is_null($page)) {
            $args = array("category__in" => array($cat), "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc');
        } else {
            if ((is_null($cat) || $cat == 0) && !is_null($page)) {
                $args = array("paged" => $page, "posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc');
            } else {
                $args = array("posts_per_page" => $posts_per_page, "post_status" => "publish", 'post_type' => 'post', 'orderby' => 'post_date', 'order' => 'desc');
            }
        }
    }
    if (!is_null($cat)) {
        $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat);
        $count_total = count($posts);
    } else {
        $cat_case = get_category_by_slug('case');
        $cat_interview = get_category_by_slug('interview');
        $cat_personnel = get_category_by_slug('personnel');
        $cat_special = get_category_by_slug('special-column');
        $cat_news = get_category_by_slug('news');
        $posts = get_posts('post_status=publish&numberposts=-1&category=' . $cat_case . ',' . $cat_interview . ',' . $cat_personnel . ',' . $cat_special . ',' . $cat_news);
        $count_total = count($posts);
    }
    $the_query = new WP_Query($args);
    $resultData = new resultData();
    $resultList = array();
    $resultData->count_total = $count_total;
    while ($the_query->have_posts()) {
        $the_query->the_post();
        $post = new postData();
        $post->title_plain = get_the_title();
        $post->url = get_permalink();
        $post->thumbnail = get_template_directory_uri() . "/timthumb.php?src=" . post_thumbnail_src() . "&h=168&w=224&zc=1";
        $post->excerpt = get_the_excerpt();
        $post->date = get_the_date('20y-m-d');
        $post->author_name = get_author_name();
        $post->views = getPostViews(get_the_ID());
        $the_post_category = get_the_category(get_the_ID());
        $post->category_name = $the_post_category[0]->cat_name;
        $the_post_category = get_the_category(get_the_ID());
        $catSlug = $the_post_category[0]->slug;
        $post->category_slug = $catSlug;
        $resultList[] = $post;
    }
    $resultData->posts = $resultList;
    header("Content-type: application/json");
    echo json_encode($resultData);
    wp_reset_query();
    die;
}
Ejemplo n.º 17
0
 public function fetchCategoryBySlug($slug)
 {
     $category = get_category_by_slug($slug);
     if (!isset($category->term_id)) {
         return null;
     } else {
         return new Category($category);
     }
 }
Ejemplo n.º 18
0
function nm_home_tabs($cats, $width = 463, $height = 210)
{
    $cats = explode(',', $cats);
    $cat = get_category_by_slug($cats[0]);
    $cat = get_category($cat->category_parent);
    echo '<div id="tab-instance-' . $cat->slug . '" class="tabs" style="width: ' . $width . 'px;"><ul class="tabs-nav">';
    $class = ' class="tabs-nav-active"';
    //Generate the nav from the cats
    foreach ($cats as $cat) {
        $cat = get_category_by_slug($cat);
        echo '<li><a id="a-' . $cat->slug . '"' . $class . ' href="javascript:show_home_tab(\'a-' . $cat->slug . '\')">' . $cat->name . '</a></li>';
        $class = '';
    }
    echo '</ul><div class="tabs-content" style="height: ' . $height . 'px;">';
    foreach ($cats as $cat) {
        echo '<ul id="ul-' . $cat . '" class="tabs-content-ul">';
        //Check if is older then 3 days, if is then order by rand
        $orderby = '';
        query_posts('showposts=1&category_name=' . $cat);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                $older = date('YMD');
                $days_since = floor((date('U') - get_the_time('U')) / 86400);
                if ($days_since >= 4) {
                    $orderby = '&orderby=rand';
                }
            }
        }
        query_posts('showposts=5&category_name=' . $cat . $orderby);
        if (have_posts()) {
            while (have_posts()) {
                the_post();
                global $post;
                echo '<li class="tabs-content-item">
					<h4><a href="' . get_permalink() . '">' . $post->post_title . '</a></h4>' . '<a href="' . get_permalink() . '">' . article_image($post->ID, 'small', true) . '</a>';
                echo '<p>';
                wswwpx_content_extract('', '15', '15', 2, '', '', TRUE, FALSE);
                echo '</p>';
                echo '<p class="tabs-content-meta">';
                echo '<a href="' . get_permalink() . '">';
                comments_number('No Comments', '1 Comment', '% Comments');
                echo '</a> | Posted: ';
                the_time('l, F jS, Y');
                echo ' | By: <a href="' . getProfileLink($post->post_author) . '">';
                the_author();
                echo '</a>';
                echo '</p>';
                echo '</li>';
            }
        }
        echo '</ul>';
    }
    echo '</div>
		</div>';
}
 public function check_parent_name($cat_id)
 {
     $curr_cat = get_category_parents($cat_id, false, '/', true);
     //echo "curr_cat";
     //var_dump($curr_cat);
     $curr_cat = explode('/', $curr_cat);
     $this->parent_catName = get_category_by_slug($curr_cat[0])->cat_name;
     return get_category_by_slug($curr_cat[0])->cat_name;
     //echo	$this -> parent_catslug;
 }
Ejemplo n.º 20
0
function bradythink_category_posts($query = false)
{
    // Bail if not home, not a query, not main query, or if it's the admin area or a feed
    if (!$query->is_category || !is_a($query, 'WP_Query') || !$query->is_main_query() || $query->is_admin || $query->is_feed) {
        return;
    }
    // only get posts not in sticky posts
    $query->set('post__not_in', get_option('sticky_posts'));
    // only get posts in this category (not in child categories)
    $query->set('category__in', get_category_by_slug(get_query_var('category_name'))->cat_ID);
}
Ejemplo n.º 21
0
function acf_load_resource_field_choices($field)
{
    // get the values & establish class
    $idObj = get_category_by_slug('program-resources');
    $id = $idObj->term_id;
    $cats = get_categories(array('hide_empty' => 0, 'parent' => $id, 'fields' => 'id=>name'));
    //Establish the target array
    $field['choices'] = $cats;
    // return the field
    return $field;
}
 static function search_handler()
 {
     if (strtok($_SERVER["REQUEST_URI"], '?') == '/search' && $_GET['s']) {
         $search_options = array('s' => $_GET['s'], 'post_type' => 'post');
         if ($_GET['cat']) {
             $search_options['cat'] = get_category_by_slug($_GET['cat'])->term_id;
         }
         query_posts($search_options);
         include 'search.php';
         exit;
     }
 }
function return_child_cat($parentslug, $link = NULL)
{
    $catslug = get_category_by_slug($parentslug);
    foreach (get_the_category() as $childcat) {
        if (cat_is_ancestor_of($catslug->term_id, $childcat)) {
            if ($link == NULL) {
                return $childcat->cat_name;
            } else {
                return '<a href="' . get_category_link($childcat->term_id) . '">' . $childcat->cat_name . '</a>';
            }
        }
    }
}
function Grafik_Shortcode_PaginatedPosts_Callback($atts)
{
    // Content Buffer...
    $content = '';
    // Query Params...
    $a = shortcode_atts(array('category' => '', 'perpage' => 10, 'class' => '', 'id' => ''), $atts, "PaginatedPosts");
    // Convert Category Slugs to IDs...
    $category_list = explode(",", $a['category']);
    foreach ($category_list as $key => $val) {
        if (is_numeric($val)) {
            continue;
        }
        $is_negative = substr($val, 0, 1) == "-";
        $trim_val = trim($val, "-");
        $category = get_category_by_slug($trim_val);
        $category_list[$key] = ($is_negative ? "-" : null) . $category->term_id;
    }
    $a['category'] = implode(",", $category_list);
    // Paging...
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    $PaginatedPosts_Args = array('posts_per_page' => $a['perpage'], 'cat' => $a['category'], 'paged' => $paged);
    // Filters...
    $grafik_filters = get_option("grafik-filters");
    if (!is_array($grafik_filters)) {
        $grafik_filters = json_decode($grafik_filters, true);
    }
    // Display Posts Matching Query...
    wp_reset_postdata();
    $PaginatedPosts_Query = new WP_Query($PaginatedPosts_Args);
    if ($PaginatedPosts_Query->have_posts()) {
        while ($PaginatedPosts_Query->have_posts()) {
            $PaginatedPosts_Query->the_post();
            $info_categories = array();
            $GRAFIK_CATEGORIES = wp_get_post_categories(get_the_ID());
            foreach ($GRAFIK_CATEGORIES as $key => $val) {
                $cat = get_category($val);
                // Filter Uncategorized from display...
                if (is_array($grafik_filters['category-masking']) && in_array($cat->term_id, $grafik_filters['category-masking'])) {
                    continue;
                }
                $info_categories[] = '<span class="theme-paginatedposts-category ' . $cat->slug . '">' . $cat->name . '</span>';
            }
            $content .= '<div class="theme-paginatedposts-post">' . '<div class="theme-paginatedposts-info">Posted: ' . get_the_date('F dS, Y') . '</div>' . '<div class="theme-paginatedposts-title">' . '<a href="' . get_permalink() . '">' . get_the_title() . '</a>' . '</div>' . '<div class="theme-paginatedposts-categories">' . implode('', $info_categories) . '</div>' . '<div class="theme-paginatedposts-short">' . get_the_excerpt() . '</div>' . '</div>';
        }
        $big = 999999999;
        $PaginatedPost_Args = array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $PaginatedPosts_Query->max_num_pages);
        $content .= '<div class="theme-paginatedposts-pagelinks">' . paginate_links($PaginatedPost_Args) . '</div>' . wp_reset_postdata();
    }
    return '<div class="theme-paginatedposts' . (empty($a['class']) ? null : ' ' . $a['class']) . '"' . (empty($a['id']) ? null : ' id="' . $a['id'] . '"') . '>' . $content . '</div>';
}
Ejemplo n.º 25
0
function filesDir($catSlug)
{
    // Use english site for filedir.
    global $switched;
    switch_to_blog(2);
    if (!$catSlug) {
        $catSlug = 'sales';
    }
    $cat = get_category_by_slug($catSlug);
    $catID = $cat->term_id;
    $output = '<ul class="filedir">';
    $parents = get_categories(array('hierarchical' => false, 'include' => $catID, 'hide_empty' => 0));
    if (!empty($parents)) {
        foreach ($parents as $parent) {
            $children = get_categories(array('hierarchical' => false, 'parent' => $parent->term_id, 'hide_empty' => 0));
            foreach ($children as $child) {
                $output .= '<li class="folder">' . $child->name . '</li>';
                $output .= '<ul>';
                $output .= renderFiles($child->term_id);
                $subchildren = get_categories(array('hierarchical' => false, 'parent' => $child->term_id, 'hide_empty' => 0));
                foreach ($subchildren as $subchild) {
                    $output .= '<li class="folder">' . $subchild->name . '</li>';
                    $output .= '<ul>';
                    $output .= renderFiles($subchild->term_id);
                    $sub_2_children = get_categories(array('hierarchical' => false, 'parent' => $subchild->term_id, 'hide_empty' => 0));
                    foreach ($sub_2_children as $sub_2_child) {
                        $output .= '<li class="folder">' . $sub_2_child->name . '</li>';
                        $output .= '<ul>';
                        $output .= renderFiles($sub_2_child->term_id);
                        $sub_3_children = get_categories(array('hierarchical' => false, 'parent' => $sub_2_child->term_id, 'hide_empty' => 0));
                        foreach ($sub_3_children as $sub_3_child) {
                            $output .= '<li class="folder">' . $sub_3_child->name . '</li>';
                            $output .= '<ul>';
                            $output .= renderFiles($sub_3_child->term_id);
                            $output .= '</ul>';
                        }
                        $output .= '</ul>';
                    }
                    $output .= '</ul>';
                }
                $output .= '</ul>';
            }
            $output .= renderFiles($catID);
        }
    }
    restore_current_blog();
    $output .= '</ul>';
    return $output;
}
Ejemplo n.º 26
0
function getNews()
{
    $newsObj = get_category_by_slug('news');
    $newsId = $newsObj->term_id;
    if (have_posts()) {
        query_posts('cat=' . $newsId);
        while (have_posts()) {
            the_post();
            ?>
        <div class="col-md-4">
            <article class="blog-post">
                <figure>
                    <a href="<?php 
            echo get_permalink();
            ?>
" class="single_image">
                        <div class="blog-img-wrap">
                            <div class="overlay">
                                <i class="fa fa-search"></i>
                            </div>
                            <img src="<?php 
            $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id(), 'Full Size');
            echo $large_image_url[0];
            ?>
" alt="<?php 
            the_title();
            ?>
"/>
                        </div>
                    </a>
                    <figcaption>
                    <h2><div href="#" class="blog-category"><?php 
            the_title();
            ?>
</a></h2>
                    <p><?php 
            the_excerpt();
            ?>
</p>
                    </figcaption>
                </figure>
            </article>
        </div>

    <?php 
        }
    }
    wp_reset_query();
}
 private function get_data()
 {
     $recent = array('show' => array(), 'fringe' => array());
     $fringe_arguments = array('numberposts' => 1, 'post_type' => 'episode', 'post_status' => 'publish');
     $recent['fringe'] = wp_get_recent_posts($fringe_arguments);
     $uncategorized = get_category_by_slug('uncategorized');
     $fringe = get_category_by_slug('tf');
     $show_arguments = array('numberposts' => 1, 'post_type' => 'episode', 'post_status' => 'publish', 'post__not_in' => array($recent['fringe'][0]['ID']));
     if ($uncategorized || $fringe) {
         $arguments['category__not_in'] = array($uncategorized->term_id, $fringe->term_id);
         //var_dump($arguments);
     }
     $recent['show'] = wp_get_recent_posts($show_arguments);
     return $recent;
 }
Ejemplo n.º 28
0
function getListCategory($slug)
{
    $parentId = get_category_by_slug($slug);
    $args = array('orderby' => 'category_order', 'order' => 'DESC', 'parent' => $parentId->term_id, 'taxonomy' => 'category', 'hide_empty' => 0);
    $categories = get_categories($args);
    $sorted_cats = array();
    foreach ($categories as $cat) {
        $ordr = get_field('category_order', 'category_' . $cat->term_id);
        $cat->order = $ordr;
        $sorted_cats[] = $cat;
    }
    usort($sorted_cats, function ($a, $b) {
        return $a->order - $b->order;
    });
    return $sorted_cats;
}
Ejemplo n.º 29
0
/**
 * Petrichor
 * (c) Web factory Ltd, 2013
 */
function wf_theme_import_demo_misc()
{
    global $wpdb;
    $options = array();
    $slider = (int) get_category_by_slug('iphone-slider')->term_id;
    $page_404 = get_page_by_title('Page not found (error 404)');
    $page_blog = get_page_by_path('blog');
    $page_front = get_page_by_path('front-page');
    $options['slider_category'] = $slider;
    $options['page_404_id'] = $page_404->ID;
    update_option(WF_THEME_OPTIONS, $options);
    update_option('blogname', 'Petrichor');
    update_option('show_on_front', 'page');
    update_option('page_for_posts', $page_blog->ID);
    update_option('page_on_front', $page_front->ID);
}
 public function map($input)
 {
     if ($input == null) {
         return null;
     }
     if (!is_array($input) && $this->taxonomy != NULL) {
         $searchby = $this->searchby;
         $input = array($searchby => $input, 'taxonomy' => $this->taxonomy);
     }
     if (is_array($input)) {
         $taxonomy = $input['taxonomy'];
         if (isset($input['slug'])) {
             $slug = $input['slug'];
             $obj = get_term_by('slug', $slug, $taxonomy);
             if (is_object($obj)) {
                 return $obj->term_id;
             }
         } else {
             if (isset($input['name'])) {
                 $name = $input['name'];
                 $obj = get_term_by('name', $name, $taxonomy);
                 if (is_object($obj)) {
                     return $obj->term_id;
                 }
             }
         }
     } else {
         $obj = get_category_by_slug($input);
         if (is_object($obj)) {
             return $obj->term_id;
         }
     }
     if ($this->createTerms) {
         if (is_array($input)) {
             if (isset($input['slug'])) {
                 return wp_insert_term($input['slug'], $input['taxonomy']);
             } else {
                 if (isset($input['name'])) {
                     return wp_insert_term($input['name'], $input['taxonomy']);
                 }
             }
         } else {
             return wp_insert_term($input);
         }
     }
     return null;
 }