How can i list custom post type categories?

This will list the 3 most recent posts from the post type us_portfolio. <?php $args = array( ‘posts_per_page’ => 3, ‘post_type’ => ‘us_portfolio’ ); $custom_query = new WP_Query($args); while ($custom_query->have_posts()) : $custom_query->the_post(); ?> <div class=”image bg-image” style=”background-image: url(‘<?php the_post_thumbnail_url(‘full’); ?>’)”></div> <?php the_category(); ?> <h3> <a title=”<?php the_title(); ?>” href=”https://wordpress.stackexchange.com/questions/289627/<?php the_permalink(); ?>”> <?php the_title(); ?> </a> … Read more

Splitting Shortcode Attributes not working

The var_dump() before using shortcode_atts() reveals the problem. Lets look at that output in a more readable format: array(5) { [0] => string(42) “phonePrefix=”0581″,phoneFlatOption=”true”,” [1]=> string(21) “accessModeDsl=”true”,” [2]=> string(24) “accessModeCable=”false”,” [3]=> string(22) “accessModeLte=”false”,” [“accessmodesat”]=> string(5) “false” } As you can see, the attributes are not being parsed correctly. Instead of ‘attribute’ => ‘value’ you’re getting … Read more

If numberposts = -1 offset won’t work

This problem has pretty simple explanation 😉 All you need to do is to take a look at Codex page for WP_Query and read about offset parameter: offset (int) – number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround). … Read more

Shortcodes output in the wrong order

the_time() is the problem here. It echoes its output. Shortcodes, effectively, happen in this order: The text containing shortcodes is parsed to find shortcodes. Each shortcode is executed and its output stored. Each shortcode is replaced with its output. The problem is that if you echo inside a shortcode, its output will be printed to … Read more

passing multiple parents value into a shortcode

If you’re passing in a comma-delimited list of parent IDs when you call the shortcode, it’s pretty easy to turn this to an array. For example, using [scname parent=”5,10,15″]: function andrew_child_loop_shortcode_new ( $atts ) { global $post; $thePostID = $post->ID; $atts = shortcode_atts( array( ‘posts’ => 20, ‘parent’ => $thePostID ), $atts ); // Turn … Read more

Creating a Slider Shortcode Based on Nivo Slider

that’s will be nested shortcodes, so you will need [slider] and [image] shortcode add_shortcode( ‘nivo_slider’, ‘nivo_slider_func’ ); function nivo_slider_func( $atts, $content = null ) { $output=”<div class=”slider-wrapper theme-default”>”; $output .= ‘<div id=”slider” class=”nivoSlider”>’; $output .= do_shortcode($content); $output .= ‘</div></div>’; return $output; } add_shortcode( ‘image’, ‘nivo_image_shortcode’ ); function nivo_image_shortcode( $atts, $content = null ) { extract( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)