Support

Account

Forum Replies Created

  • Thank you so much for that!! it worked a treat 😀

  • Hi John.. I think that fixed it.. thank you so much!!

  • I think I spoke to soon.. Its 99% there.. I seem to have an issue now which is rather frustrating… I’m getting them to display correctly.. but now when I look in different categories (I have set up 2 different categories), i’m getting both the child categories display… even though they are from different parent categories..

    http://whyttip.eu/index.php/meps/bulgaria/
    http://whyttip.eu/index.php/meps/belgium/

    password: ecr_group

    for some strange reason they are both displaying even though one sub category (Bulgaria Without Censorship (България без цензура)) is for Bugaria and the other (New Flemish Alliance (Nieuw-Vlaamse Alliantie)) is for Belgium.

    The code i’m using is below. Can anyone help me work this out?

    <div class="blog-default">
    				<div class="master_container container">
    					<section class="page_content col-xs-12 col-md-12">
    						<div class="blog-default-bg">
    						
    						<h2>YOUR MEPS</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla fringilla, orci ut mattis lacinia, enim risus hendrerit ante, fringilla fringilla turpis diam efficitur lectus. Donec sagittis, quam a pellentesque dictum, odio sapien porta eros, eget cursus nibh orci nec purus. Curabitur blandit tincidunt blandit. Morbi fermentum urna sed lacus condimentum scelerisque. Nunc vitae mauris sit amet lectus euismod accumsan.</p>
    <form id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get">
            <input class="inlineSearch" type="text" name="s" placeholder="Search" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" />
    		<input type="hidden" name="post_type" value="mep" />
            <?php wp_dropdown_categories( 'show_option_none=Select Country&show_count=1&hierarchical=1&taxonomy=meps_category&depth=1' ); ?>
    		<?php wp_dropdown_categories( 'show_option_none=Select Group&show_count=1&hierarchical=0&taxonomy=meps_category&depth=1' ); ?>
    		<input class="inlineSubmit" id="searchsubmit" type="submit" alt="Submit" value="Submit" />
    </form>
    <br/>
    <?php $currentCat = $_GET['cat'];?>
    <?php $loop = new WP_Query(array('post_type'=>'mep', 'cat'=>$currentCat, 'order' => 'asc')); ?>
    <strong><?php echo single_cat_title();?> - Groups and MEPs:</strong>
    <div class="clear"></div>
    <br/>
    
    <div id="accordion" class="panel-group">
        <div class="panel panel-default">
    <!-- SUB CATEGORY TITLE AREA -->
    <?php 
    $member_group_terms = get_terms( 'meps_category', array(
    	'child_of' => $currentCat,
    	'hierarchical' => false
     ) );
    ?>
    <?php
    foreach ( $member_group_terms as $member_group_term ) {
        $member_group_query = new WP_Query( array(
            'post_type' => 'mep',
            'tax_query' => array(
                array(
                    'taxonomy' => 'meps_category',
                    'field' => 'slug',
                    'terms' => array( $member_group_term->slug ),
    				'operator' => 'IN' 
                )
            )
        )
    	);?>
            <div class="panel-heading">
    		<!--<div class="col-md-2"><img src="#" /></div>-->
    			<div class="col-md-12"><h3><?php echo $member_group_term->name; ?></h3>
    			<p><?php echo $member_group_term->description; ?></p></div>
    			<div class="clear bottomgap"></div>
    			<div class="col-md-8"></div><div class="col-md-4"><a data-toggle="collapse" data-parent="#accordion" class="button" href="#<?php echo $member_group_term->term_id; ?>">View MEPs</a> <a href="<?php echo $member_group_term->mep_party_link; ?>" class="button" target="_blank">Visit Website</a></div>
            <div class="clear"></div>
    		</div>
    <div class="clear"></div>
    
    <!-- END SUB CATEGORY TITLE AREA -->
            <div id="<?php echo $member_group_term->term_id; ?>" class="panel-collapse collapse col-md-12">
    <!-- SUB CATEGORY POSTS AREA -->
    <?php  if ( $member_group_query->have_posts() ) : ?>
    		<?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
                <div class="panel-body">
    			<div class="col-md-2 meppic"><?php the_post_thumbnail(); ?></div>
    			<div class="col-md-10"><h3 class="mepname"><?php echo the_title();?></h3>
    			<strong><?php the_field('title_position'); ?></strong>
    			<div class="clear"></div>
    			<?php the_field('location'); ?>
    			<div class="clear"></div>
    			<br/>
                <?php the_field('description'); ?>
    			<div class="clear"></div>
    			<br/>
    			<div class="mepdetails"><div class="col-md-3 first"><strong>Email:</strong> <a href="mailto:<?php the_field('email'); ?>"><?php the_field('email'); ?></a></div><div class="col-md-3"><strong>Website:</strong> <a href="http://<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a></div><div class="col-md-3"><strong>Tel:</strong> <?php the_field('tel'); ?></div><div class="col-md-3 last"><a href="http://www.twitter.com/<?php the_field('twitter_id'); ?>" target="_blank"><?php the_field('twitter_id'); ?></a></div></div>
    			</div>
    			</div>
    <!-- END SUB CATEGORY POSTS AREA -->
    <?php
    endwhile;
    ?>
    </div>
    <?php endif; ?>
    <?php
        // Reset things, for good measure
    	$member_group_query = null;
        wp_reset_postdata();
    }
    ?> 
    </div>
    </div>
    </div>
    </section>
    </div>
    </div>
  • Terribly Sorry… don’t know why it didn’t work…

    <?php
    $member_group_terms = get_terms( ‘systemcontents_category2′);
    $selected = get_sub_field(‘system_contents_posts’);
    ?>
    <?php
    foreach ( $member_group_terms as $member_group_term ) {
    $member_group_query = new WP_Query( array(
    ‘post_type’ => ‘pj_systemcontents2′,
    ‘systemcontents_category2′ => $selected,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘systemcontents_category2′,
    ‘field’ => ‘slug’,
    ‘terms’ => array( $member_group_term->slug ),
    ‘operator’ => ‘IN’
    )
    )
    )
    );?>
    <?php if ( $member_group_query->have_posts() ) : ?>
    <h3><?php echo $member_group_term->name; ?></h3>
    
    <?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
    <?php echo get_post_meta($post->ID,’document-section’,true) ?>
    <?php echo get_post_meta($post->ID,’document-reference’,true) ?> <?php echo get_post_meta($post->ID,’document-sub-section’,true) ?>
    <?php endwhile; ?>
    
    <?php endif; ?>
    <?php
    // Reset things, for good measure
    $member_group_query = null;
    wp_reset_postdata();
    }
    ?>
  • I CRACKED IT…. it needed to be ‘hierarchical’ => false and it worked!!!!

  • when i set the ‘child_of’ => $currentCat in the get_terms array… it just reverts to displaying both categories again..

  • right.. so I need the top level category to be dynamic for the one that you are currently viewing… I tried to do the following extra code to load this as current category:
    <?php $currentCat = $_GET[‘cat’];?>

    But its not working still…

    I have set as ‘parent’ => $currentCat within the get_terms array, but it now just displays the current category only (the Parent category).

    The weirdest thing is… is that the post that is displaying isn’t in the parent category at all (its not selected to anyway), its only in the child category.. so it should be displaying / appearing below the child category not the parent….

    Its not making much sense …

  • I’ve tried the below and also tried the ‘parent’ => 0.

    If I do the below, nothing happens. If I do the ‘parent’ => 0 it removes the subcategory and only shows the parent… there must be something i’m doing wrong 🙁

    <?php 
    $member_group_terms = get_terms( 'meps_category', array(
    	'child_of' => 0
     ) );
    ?>
    <?php
    foreach ( $member_group_terms as $member_group_term ) {
        $member_group_query = new WP_Query( array(
            'post_type' => 'mep',
            'tax_query' => array(
                array(
                    'taxonomy' => 'meps_category',
                    'field' => 'slug',
                    'terms' => array( $member_group_term->slug ),
    				'operator' => 'IN' 
                )
            )
        )
    	);?>
  • that sooooo close!

    Its still showing the parent category at the top, which is wrong… but its now showing the child category below, which is right.

    <div id="accordion" class="panel-group">
        <div class="panel panel-default">
    <!-- SUB CATEGORY TITLE AREA -->
    <?php $member_group_terms = get_terms( 'meps_category' ); ?>
    <?php
    foreach ( $member_group_terms as $member_group_term ) {
        $member_group_query = new WP_Query( array(
            'post_type' => 'mep',
            'tax_query' => array(
                array(
                    'taxonomy' => 'meps_category',
    				'parent' => $currentCat,
                    'field' => 'slug',
                    'terms' => array( $member_group_term->slug ),
                    'operator' => 'IN',
                )
            )
        )
    	);
        ?>
            <div class="panel-heading">
    		<!--<div class="col-md-2"><img src="#" /></div>-->
    			<div class="col-md-12"><h3><?php echo $member_group_term->name; ?></h3>
    			<p><?php echo $member_group_term->description; ?></p></div>
    			<div class="clear bottomgap"></div>
    			<div class="col-md-8"></div><div class="col-md-4"><a data-toggle="collapse" data-parent="#accordion" class="button" href="#<?php the_ID(); ?>">View MEPs</a> <a href="#" class="button" target="_blank">Visit Website</a></div>
            <div class="clear"></div>
    		</div>
    <div class="clear"></div>
    <?php  if ( $member_group_query->have_posts() ) : ?>
    <!-- END SUB CATEGORY TITLE AREA -->
            <div id="<?php the_ID(); ?>" class="panel-collapse collapse col-md-12">
    <!-- SUB CATEGORY POSTS AREA -->
    		<?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
                <div class="panel-body">
    			<div class="col-md-2 meppic"><?php the_post_thumbnail(); ?></div>
    			<div class="col-md-10"><h3 class="mepname"><?php echo the_title();?></h3>
    			<strong><?php the_field('title_position'); ?></strong>
    			<div class="clear"></div>
    			<?php the_field('location'); ?>
    			<div class="clear"></div>
    			<br/>
                <?php the_field('description'); ?>
    			<div class="clear"></div>
    			<br/>
    			<div class="col-md-3 first"><strong>Email:</strong> <a href="mailto:<?php the_field('email'); ?>"><?php the_field('email'); ?></a></div><div class="col-md-3"><strong>Website:</strong> <a href="<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a></div><div class="col-md-3"><strong>Tel:</strong> <?php the_field('tel'); ?></div><div class="col-md-3 last"><a href="http://www.twitter.com/<?php the_field('twitter_id'); ?>" target="_blank"><?php the_field('twitter_id'); ?></a></div>
    			</div>
    			</div>
    <!-- END SUB CATEGORY POSTS AREA -->
            </div>
    		<?php
    endwhile;
    ?>
    <?php endif; ?>
    <?php
        // Reset things, for good measure
    	$member_group_query = null;
        wp_reset_postdata();
    }
    ?>
        </div>
    </div>
  • tried the below instead.. it displays the category information, but below the post (see the screenshot) which makes no sense, as it should be displaying it where it says Belgium, and then when you press the expander it will display the posts (the MEPs) underneath.

    <div id="accordion" class="panel-group">
        <div class="panel panel-default">
    <!-- SUB CATEGORY TITLE AREA -->
    <?php $member_group_terms = get_terms( 'meps_category' ); ?>
    <?php
    foreach ( $member_group_terms as $member_group_term ) {
        $member_group_query = new WP_Query( array(
            'post_type' => 'mep',
            'tax_query' => array(
                array(
                    'taxonomy' => 'meps_category',
    				'parent' => $parentcat,
                    'field' => 'slug',
                    'terms' => array( $member_group_term->slug ),
                    'operator' => 'IN',
                )
            )
        )
    	);
        ?>
            <div class="panel-heading">
    		<div class="col-md-2"><?php echo $member_group_term->category_image; ?></div>
    			<div class="col-md-10"><h3><?php echo $member_group_term->name; ?></h3>
    			<p><?php echo $member_group_term->description; ?></p></div>
    			<div class="clear bottomgap"></div>
    			<div class="col-md-8"></div><div class="col-md-4"><a data-toggle="collapse" data-parent="#accordion" class="button" href="#<?php the_ID(); ?>">View MEPs</a> <a href="#" class="button" target="_blank">Visit Website</a></div>
            <div class="clear"></div>
    		</div>
    <div class="clear"></div>
    <?php  if ( $member_group_query->have_posts() ) : ?>
    <!-- END SUB CATEGORY TITLE AREA -->
            <div id="<?php the_ID(); ?>" class="panel-collapse collapse col-md-12">
    <!-- SUB CATEGORY POSTS AREA -->
    		<?php while ( $member_group_query->have_posts() ) : $member_group_query->the_post(); ?>
                <div class="panel-body">
    			<div class="col-md-2 meppic"><?php the_post_thumbnail(); ?></div>
    			<div class="col-md-10"><h3 class="mepname"><?php echo the_title();?></h3>
    			<strong><?php the_field('title_position'); ?></strong>
    			<div class="clear"></div>
    			<?php the_field('location'); ?>
    			<div class="clear"></div>
    			<br/>
                <?php the_field('description'); ?>
    			<div class="clear"></div>
    			<br/>
    			<div class="col-md-3 first"><strong>Email:</strong> <a href="mailto:<?php the_field('email'); ?>"><?php the_field('email'); ?></a></div><div class="col-md-3"><strong>Website:</strong> <a href="<?php the_field('website'); ?>" target="_blank"><?php the_field('website'); ?></a></div><div class="col-md-3"><strong>Tel:</strong> <?php the_field('tel'); ?></div><div class="col-md-3 last"><a href="http://www.twitter.com/<?php the_field('twitter_id'); ?>" target="_blank"><?php the_field('twitter_id'); ?></a></div>
    			</div>
    			</div>
    <?php
    endwhile;
    endif;
    ?>
    <?php
        // Reset things, for good measure
        $member_group_query = null;
        wp_reset_postdata();
    }
    ?>
    <!-- END SUB CATEGORY POSTS AREA -->
            </div>
    
        </div>
    </div>

    Any help to fix this would be awesome!

  • Unfortunately that didn’t work. All it ends up doing is displaying the full URL of the image instead of the image itself.

    I decided not to worry about making it a shortcode. I have instead just made a template using the <?php method instead which seems to work perfectly 🙂

    Thanks for your help though Hube2 🙂

  • Could you point me out where this code isn’t working with the update_field option:

    HTML
    on the button id=”rsvp_button”

    PHP (in the functions.php file)
    function my_action_callback() {

    global $post; // You still may need to pass the POST ID here from the JS ajax.
    // get each post by ID
    $postID = $post->ID;
    // get the post’s custom fields
    $custom = get_post_custom($postID);
    // find the view count field
    $views = intval($custom[‘number_attending’][0]);
    // increment the count
    if($views > 0) {
    update_field($postID, ‘number_attending’, ($views + 1));
    } else {
    update_field($postID, ‘number_attending’, 1, true);
    }
    die(); // this is required to return a proper result
    }
    add_action(‘wp_ajax_my_action’, ‘my_action_callback’);

    JS (in the header.php)
    <script type=”text/javascript”>
    jQuery(‘body’).on(‘click’,’#rsvp_button’,function($){
    var data = { action: ‘my_action’ };

    $.post(ajaxurl, data, function(response) {
    });
    });
    </script>

    For some reason the sets above don’t seem to work.

    Any help would be great 🙂

    Chris

Viewing 12 posts - 1 through 12 (of 12 total)