Pagination for custom posts loop

Post loop with pagination in the shortcode [title-snippet type=”post” limit=”5″]: function wpc_shortcode_title( $atts ) { extract( shortcode_atts( array( ‘limit’ => 5, ‘type’ => ‘post’), $atts ) ); $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1; query_posts( array ( ‘posts_per_page’ => $limit, ‘post_type’ => $type, ‘order’ => ‘ASC’, ‘orderby’ =>’menu_order’, ‘paged’ => $paged ) ); $list=” “; … Read more

Image path in childs theme

Use the ABSPATH constant defined in the wp-config.php: $filename = ABSPATH . ‘wp-content/uploads/webcam/webcamimage.jpg’; You don’t have to use basename() function since it would return only the last component from the full file path, i.e. webcamimage.jpg, and it isn’t what you want to use with filemtime() function.

Last updated posts shortcode in functions.php

You can do this like bellow // register shortcode add_shortcode(‘last-modified’, ‘last_mofied_shortcode_callback’); function last_mofied_shortcode_callback() { $output=”<ol class=”list-numbered”>”; $recently_updated_posts = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ’13’, ‘orderby’ => ‘modified’, ‘no_found_rows’ => ‘true’ // speed up query when we don’t need pagination ) ); if ( $recently_updated_posts->have_posts() ) : while( $recently_updated_posts->have_posts() ) : $recently_updated_posts->the_post(); $output … Read more

Function to function shortcode help [closed]

Not sure what you would need this for but this is how you take the data of the variable $result from the operation function to your shortcode: operation(); function operation(){ $result=5+1; return $result; } function my_function(){ $result = operation(); return (string)$result; } add_shortcode( ‘my-shortcode’, ‘my_function’ );

Display a custom name when the user has no name settle in his account

Use PHP ternary comparsion operator to check if get_user_meta() function returns blank or non-blank result: function colaborador_nome($atts) { if (is_user_logged_in() && !is_feed()) { return ‘&nbsp;’. (get_user_meta( get_current_user_id(), ‘first_name’, true ) ?: “Hi >No Name<, please settle your name in your account.”); } } add_shortcode(‘colaborador_nome’, ‘colaborador_nome’);