Getting a variable inside foreach from PHP to JS after localization
You have wp_enqueue_script( ‘showMake’ ); twice. Remove the last line from your sdm_load_javascript_files function and see if it works.
You have wp_enqueue_script( ‘showMake’ ); twice. Remove the last line from your sdm_load_javascript_files function and see if it works.
What you’re getting is an array so you need to implode() them – the Walker_Nav_Menu has something like this: $class_names = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, array_filter( $classes ), $item ) ) ); So you can modify your foreach to implode them in a similar fashion $class = esc_attr( implode( ‘ ‘, apply_filters( ‘nav_menu_css_class’, … Read more
Do the categories all have posts, change line 2 to: $categories = wp_list_categories(‘hide_empty=0&title_li=0&child_of=”.$categoryslug->term_id”); This sets it to display all categories even if empty If that doesn’t work then you need to echo each part and find the cause of the “error” so echo each element e.g. echo $categoryslug; if that works then change to echo … Read more
You don’t need to alter the code for different formatting, you can simply use the :first-child pseudoclass in css. The foreach loop will, presumably, generate similar blocks of code, structured like this: <div class=”all-my-posts”> <article class=”my-slider-post”> … </article> <article ..> </article> … </div> Now you can simply addres the first <article> block with css like … Read more
This is more about string and array manipulation with php than a WordPress related question. The proper way to do it would be using a repeater field instead of a single text input. Advanced Custom Fields, which seems to be the plugin you are using, has a nice repeater addon. That would let the users … Read more
Since the file you send is base64 encoded, you will need to decode and save the result into a file at a temp directory. From there it is just a normal server side wordpress image manipulation and insertion of the relevant info into the DB, something that there are many examples for on this site. … Read more
This is purely PHP which is considered to be Off-topic but this is my take: <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); $i = $wp_query->current_post; echo ( 0 == $i % 3 ) ? ‘<div class=”row”>’ : ”; ?> <div class=”project”> </div> <!– /.project –> <?php echo ( … Read more
The 2nd part of the condition seems wrong basename( get_permalink() != ‘sponsor-one’) should be basename( get_permalink() ) != ‘sponsor-one’ Please check where the parenthesis ends. Also in your code if that is the only condition, then you can have an else statement instead of having another elseif.
This has to work, Im using it in several projects: add_filter( ‘excerpt_more’, ‘my_excerpt_more’ ); function my_excerpt_more( $more ) { return ”; } Just copy-paste it to your functions.php. Little bonus snippet that you might need: add_filter( ‘excerpt_length’, ‘my_excerpt_length’ ); function my_excerpt_length( $length ) { return 50; } This means that excerpt is 50 words long. … Read more
Looking at the id’s in your rendered code, the name of your parent style seems to be ‘basic-css’. That would mean you need array(‘basic-css’) as the dependency in your wp_enqueue_style. However, in the code the child style seems to be called ‘defaultbasic-css’, while you enqueue it as ‘child-style’. So it looks like there is some … Read more