Get css class of menu item in custom menu structure

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

Trying To Get Child Categories To Show, Issue With foreach Loop

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

Dividing the loop to style post differently

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

Output custom text field as unordered list

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

Convert canvas to image and upload image to server

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

Conditional string comparison failing for basename/slug

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.

Need help removing […] after excerpt

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

child parent styles enqueue order

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