I tried YYYYMMDD and yymmdd and neither works.
Still need help with this. The save and display formats are: “MM d, yy”, for what that’s worth.
Would this be easier to achieve using the gallery field?
I fixed the issue, but I want to do something additional in this function. I want to be able to also loop through all the rows and output all except the last one. I have two columns. The left will output the last row and the right will output all but the last.
function smile_gallery( $atts ) {
if( have_rows('smile_gallery', 3045) ):
$i = 0;
$html_out = '';
$html_out .= '<div class="smile-container">';
$rows = get_field('smile_gallery', 3045);
$end_row = end($rows);
$recent = $end_row['smile_week'];
$html_out .= '<div class="col-md-6">';
$html_out .= '<div class="smile-recent">';
$html_out .= $recent;
$html_out .= '</div>';
$html_out .= '</div>';
$html_out .= '<div class="col-md-6">';
$html_out .= '<div class="smile-thumbs">';
while( have_rows('smile_gallery', 3045) ): the_row();
$week = get_sub_field('smile_week', 3045);
$img = get_sub_field('smile_img', 3045);
$i++;
// Do stuff with each post here
$html_out .= '<div class="smile-img">';
$html_out .= $week;
$html_out .= '</div>';
endwhile;
$html_out .= '</div>';
$html_out .= '</div>';
$html_out .= '</div>'; // smile container
endif;
return $html_out;
}
add_shortcode( 'show_smiles', 'smile_gallery' );
This is the full function. To take it an even step further, it would be cool to order the rows by $week. $week outputs a number.
$('a[href="#directions"]').one('click',function(){
$('.hotel-map').each(function(){
// create map
map = new_map( $(this) );
});
});
Okay, after a lot of fiddling around I learned it’s because it’s inside of my bootstrap tab.
I have google.maps.event.trigger(map, ‘resize’); in my js but I guess it’s in the incorrect spot, where do I put this exactly in the documentation’s js?
I’m reading this fix, but I have no idea how to up it to 255.
Ah, changed the return value to Image Array and that worked. Whoops.
The moment I changed $image['url']
to just $image
the url outputted and no more error, but for the alt
it was still an issue.
function mbgc_gallery_shortcode( $atts ) {
// $post_id = $atts['id'];
extract( shortcode_atts(
array(
'id' => '',
), $atts )
);
$html_out = '123';
// $post = get_post( $id );
// if ( $post ) :
if( have_rows('mbgc_gallery') ):
$html_out .= '<div class="mbgc-gallery owl-carousel owl-theme">';
while( have_rows('mbgc_gallery') ): the_row();
// vars
$image = get_sub_field('mbgc_image');
$caption = get_sub_field('mbgc_caption');
$title = get_sub_field('mbgc_title');
$sub_title = get_sub_field('mbgc_sub_title');
var_dump($caption);
if ( $image ) :
$html_out .= '<div class="mbgc-gallery-item">';
if ( $caption ) :
$html_out .= '<div class="mbgc-slide-caption">';
$html_out .= '<h4>' . $caption . '</h4>';
$html_out .= '<div class="mbgc-slide-titles">';
$html_out .= '<h6>' . $title . '</h6>';
$html_out .= '<h6>' . $sub_title . '</h6>';
$html_out .= '</div>';
$html_out .= '</div>';
endif;
$html_out .= '<div class="mbgc-slide">';
$html_out .= '<img src="' . $image['url'] . '" alt="' . $image['alt'] . '" />';
$html_out .= '</div>';
$html_out .= '</div>';
endif;
endwhile;
$html_out .= '</div>';
endif;
// endif;
return $html_out;
}
add_shortcode('mbgc_gallery', 'mbgc_gallery_shortcode');
This is probably out of the scope of what you can help with, but I am trying to write a function based on what you said. Creating a Custom Post Type. I can’t get this to work though. I tried [mbgc_gallery id=”401″] and it outputs nothing, only the test 123
. I tried a var_dump
and nothing neither. Am I using the repeater code correctly?
If you see my OP, I should remove the /%product_cat% and use ACF to create terms that’ll be added to the permalink?
I’m using woocommerce to set up courses.
The courses available are for Grade 11 and Grade 12 students.
English, for example, is part of both categories and looks like this:
/grade-11/english
/grade-12/english-2
I’m trying to figure out a way to deal with this, I was thinking, because I already have a field that gets the course’s code, that I could use acf to modify the url to look like this:
/grade-11/english-eng3u
/grade-12/english-eng4u
I could do this manually in the post’s slug, but I was thinking it would be neat if it were dynamic somehow.
So there is no way to use ACF to add the value of a field to a page’s slug?
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
$grade = get_field('grade', $queried_object);
$grade = get_field('grade', $taxonomy . '_' . $term_id);
var_dump($grade);
The var_dump shows “NULL NULL NULL”
$queried_object = get_queried_object();
$grade = get_field("grade", "term_" . $queried_object->term_id);
I had to remove the last “‘” you had in order for my editor to show the concatenated variable. This doesn’t work for me though.
I also tried:
$grade = get_field(“grade”, “product_cat_term”);
$grade = get_field(“grade”, “product_cat”);
Not sure what I need to make this output correctly.
$grade = get_field(“grade”);
For some reason I can’t get this to return anything. Do I need something special to call this given that it’s a custom location rule?
YOU ARE A WIZARD.
I spent hours looking at other examples and trying on my own. Thank you so much!!
Yeah, I got the first dropdown to appear, but the product categories got tricky.
/wp-admin/term.php?taxonomy=product_cat&tag_ID=15&post_type=product&wp_http_referer=%2Fdemo%2Fchla%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dproduct_cat%26post_type%3Dproduct
/wp-admin/term.php?taxonomy=product_cat&tag_ID=16&post_type=product&wp_http_referer=%2Fdemo%2Fchla%2Fwp-admin%2Fedit-tags.php%3Ftaxonomy%3Dproduct_cat%26post_type%3Dproduct
Anyone mind helping me out, I read the link above but I’m still unsure about how to create this rule.
Hmm, this seems pretty confusing to me. Out of my depth for sure.
Still doesn’t appear, that’s what I had originally and then tried the “and”.
Sigh, I can’t even undo it, do you know how to fix it? I’d like to mark yours as the solution.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.