Support

Account

Forum Replies Created

  • Thanks John, I’ll give Multilingual Press a try and report back.

  • Hi everyone,

    Sorry to bump this thread, but am revisiting this project after a 2 month hiatus and haven’t really found any answers in the meantime, so thought I’d ask again.

    Pretty much, each text on the site will have two fields (English/Norwegian). I’m just trying to figure out a way to switch between the two via a change in the URL.

    http://www.thewebsitename.no/uk/postname or http://www.thewebsitename.no/no/postname

    Any help will be greatly appreciated.

  • As always, John, your help is prompt, instructive and never condescending for us dummies. Thank you, yet again.

  • Success! Thank you so much. Just these little things, that once known, it’s “oh, of course”. Now I know. Thanks, as always, for the great support.

    Here’s the code for anyone else on here that may have run into the same issue.

    <?php if( have_rows('testimonial_repeater', 558) ): ?>
    	<ul>
    		<?php while( have_rows('testimonial_repeater', 558) ): the_row(); 
    			$text = get_sub_field('testimonial_text');
    		?>
    			<?php if( get_sub_field('testimonial_type') == 'testimonial_type_workshops' ): ?>
    				<li>
    					<?php echo $text; ?>
    				</li>
    			<?php endif; ?>
    		<?php endwhile; ?>
    	</ul>
    <?php endif; ?>
  • Quick side note. Just for due diligence’s sake, I copy/pasted the above ‘all’ code into my Workshop page and that too gave no output. So I don’t think it’s the code.

    The only difference between Testimonials and Workshops is that Testimonials is a Page and Workshops is a Post.

    Now I really have no idea what to do?

  • Hi John, thanks so much for your reply. I tried you example and many variations of it, but I’m not getting any output onto the page. Not even wrong stuff.

    Here is the stock standard code I’ve used for the Testimonial page, where all Repeater rows are displayed.

    <div class="testimonials">
    	<?php if( have_rows('testimonial_repeater') ): ?>
    		<ul>
    		<?php while( have_rows('testimonial_repeater') ): the_row(); 
    			$text = get_sub_field('testimonial_text');
    			$type = get_sub_field('testimonial_type');
    			?>
    			<li>
    				<?php echo $text; ?>
    			</li>
    		<?php endwhile; ?>
    		</ul>
    	<?php endif; ?>
    </div>

    With the Workshop page, I want the same thing, but just the ones selected with Workshops in the Select field.

    I’ve checked for typos and done a lot of reading. Still not sure what I’m doing wrong.

    As always, any and all help is greatly appreciated.

  • Hi John, sorry, must’ve missed seeing that part. Sounds like a great addition. I’d love to test it. Might install and see how it goes. Thanks again.

  • OK, happy days. I found this handy little snippet. I applied it, changed out the values with mine and added it to my functions.php file.

    
    	// populate acf field (select_post) with post types (clients)
    
    	function acf_load_select_post( $field ) {
    		$field['choices'] = get_post_type_values( 'clients' );
    		return $field;
    	}
    	add_filter( 'acf/load_field/name=select_post', 'acf_load_select_post' );
    
    	function get_post_type_values( $post_type ) {
    		$values = array();
    		$defaults = array(
    			'post_type' => $post_type,
    			'post_status' => 'publish',
    			'posts_per_page' => -1,
    			'orderby' => 'title',
    			'order' => 'ASC'
    		);
    		$query = new WP_Query( $defaults );
    		if ( $query->found_posts > 0 ) {
    			foreach ( $query->posts as $post ) {
    				$values[get_the_title( $post->ID )] = get_the_title( $post->ID );
    			}
    		}
    		return $values;
    	}
    

    This populates the Select field on the page called Home. Huzzah!

    Now I just need to create my home page template to populate the page with the content of the selection. That would be the index.php file, right?

  • I had a thought and it goes something like this…

        Using ACF, create a new Custom Field. I’ve just called it Home.
        Create a new Field. I’ve called that Select Post (select_post).
        Choose the Field Type: Select.
        Under Location – Rules, set it to Page is equal to Home.
        Make a single page index template.

    A problem with this plan is, how to fill that Select field, with all the custom posts.

    If I can figure that out, then I’ve allowed the admin to be able to simply choose a post from a dropdown, without any further WP knowledge and bypassing the standard Page dropdown under Reading.

    I’ll start Googling and trying different things, but do you think this is achievable?

  • Thanks for the links. I gave them a read through, but I think I’m going to have to try and figure an alternative. I need the Home page to be easily changed by an admin with limited WordPress experience, which is why I was hoping to sort an easy “choose from a dropdown” option for them.

    Instead of trying to get a post shown as Home. I might have to look into setting up a page, which does nothing but shows a post. And then hopefully which post that is, can be easily changed.

    Time to put my thinking cap on.

    Thanks for replying.

  • Huzzah! I had a friend have a look at it and not only did he clean up my code, he also solved the problem. I’ll post it here for anyone that may be stuck on the same thing.

    PHP

    <?php
    	$args = array(
    		'post_type' => 'Videos'
    	);
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    		echo '<div class="grid-item thumb ';
    		foreach (get_the_terms(get_the_ID(), 'category') as $cat) { echo $cat->slug . ' '; }
    		echo '"><a href="';
    		the_field('vid_url');
    		echo '" data-lity data-signed="';
    		echo get_field('vid_signed') ? 'true' : 'false';
    		echo '" data-director="';
    		foreach (get_the_terms(get_the_ID(), 'director') as $cat) { echo $cat->name; }
    		echo '" data-title="';
    		the_title();
    		echo '">';
    		the_post_thumbnail();
    		echo '</a></div>';
    	endwhile;
    ?>

    JAVASCRIPT

    jQuery(document).on('lity:ready', function(event, lightbox) {
    	var $target 	= jQuery(event.currentTarget.activeElement),
    		director 	= lightbox.opener().data('director'),
    		title 		= lightbox.opener().data('title'),
    		signed 		= lightbox.opener().data('signed');
    	$target.find('.lity-container').prepend('<div class="lity-hover"><div class="lity-info"><h1>' + director + '</h1><h2>' + title + '</h2></div></div>');
    	if ( !signed ) {
    		$target.find('.lity-container h2').after('<h3>Here is a line about getting in contact</h3>');
    	}
    });
  • Starting to make more sense. Thanks for sticking with me on this one.

    Only problem is the thumbnail <a> isn’t written in a way that I can just add your code.

    <?php
    	$args = array(
    		'post_type' => 'Videos'
    	);
    	$loop = new WP_Query( $args );
    	while ( $loop->have_posts() ) : $loop->the_post();
    		echo '<div class="grid-item thumb ';
    		foreach (get_the_terms(get_the_ID(), 'category') as $cat) { echo $cat->slug . ' '; }
    		echo '"><a href="';
    		the_field('vid_url');
    		echo '" data-lity data-director="';
    		foreach (get_the_terms(get_the_ID(), 'director') as $cat) { echo $cat->name; }
    		echo '" data-title="';
    		the_title();
    		echo '">';
    		the_post_thumbnail();
    		echo '</a></div>';
    	endwhile;
    ?>

    So what you’re saying is: it checks if the T/F value is Signed and adds the class “issigned” to the above <a>. Then, if you click on an <a> that has the class “issigned”, that will in turn add a class to <div class="lity-data">? Is that what you’re thinking?

  • No offence, but isn’t that an even more complicated way of doing it? I say that only because I’m not smart enough to figure out either way.

    I’ve Googled all evening. I’ve tried to find how to add a class using PHP. Why is that so difficult? I’ve tried to detect the value of the True/False using PHP and then add the class using Javascript. No luck there.

    Not sure why this is so difficult for me to figure out.

    If the True/False value is “Signed”, then add the class “issigned” to <div class=”lity-info”>.

  • It’s still under construction. If you check out the Home page, you will see all the thumbnails. The first one of the girls face is a ‘freelance’ the others are ‘signed’.

    If you choose a video and you hover the player, you should see the director’s name <h1> and the client/title of the video <h2>. There is also an <h3> with a static text about getting in contact. At the moment it’s set to: display: none;.

    What I want is, if the True/False field is set to ‘Freelance’, then the <h3> gets changed to display: block;.

    I’ve tried a gazillion things and if they don’t work I remove them, so at the moment, there is no code attempting to make it do anything.

    http://nickverburgt.com/theproducers.co/

    Many thanks in advance.

  • Yes and no. I only mentioned the Javascript part, because I couldn’t use your PHP method.

    I’m just trying to detect if the chosen video is by a ‘signed’ director (or not) and if it is, then add the class.

    So, not actually changing the modal code at all. Except for the add class, of course.

  • Thanks for your reply @barrycrous.

    Having the True/False option was a better idea. I’ve also changed it so instead of having to select true/false on every single video. You just choose under each director (true/false now named: ‘dir_signed’).

    Unfortunately, the modal is added using Javascript’s ‘prepend’. This is why I was hoping to check True/False separately. And then add a class to the ‘lity-info’ <div> if it was true. Like: <div class=”lity-info istrue”>

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