How to get all child pages in their parent page?
You should use this attribute in the $args array to get children of specific page by Parent ID ‘child_of’ => 20, More information: https://codex.wordpress.org/Function_Reference/get_pages
You should use this attribute in the $args array to get children of specific page by Parent ID ‘child_of’ => 20, More information: https://codex.wordpress.org/Function_Reference/get_pages
The following is problematic in the OP’s code snippet: Missing shortcode_atts() for default attribute handling. Incorrectly defining the shortcode’s input argument, use instead function create_my_shortcode( $attr = [], $content = null ){ … } Not escaping user input, check e.g. wpdb::prepare(). We want to avoid possible SQL injections. Uses hardcoded table prefix, wp_, instead of … Read more
Get the Attribute value in the shortcode and get the custom field values: function product_func($atts) { $post_id = $atts[‘code’]; $key = “my_custom_field_key”;//for 1 field, you can do this 6 times for the 6 values $custom_value = get_post_meta($post_id, $key, true); return $custom_value; } add_shortcode(‘product’, ‘product_func’); if you want to debug the post meta field values use … Read more
Thanks to @mmm I figured it out. What I am doing now is adding the form in between php tags. EXAMPLE of what I was doing ?> <input type=”checkbox” name=”overwrite” value=”true”>Overwrite?<br> <?php What I need to be doing is adding the content that I want to add to the page into a string that is … Read more
Try this: function thebroker_agents() { global $current_user; $bmail = $current_user->user_email; $user_query = new WP_User_Query( array( ‘meta_key’ => ‘broker_email’, ‘meta_value’ => $bmail, ‘fields’ => ‘all’ ) ); $users = $user_query->get_results(); if (!empty($users)) { $results=”<ul>”; foreach ($users as $user){ $results=”<li>” . $user->display_name . ‘</li>’; } $results=”</ul>”; } else { $results=”No users found”; } wp_reset_postdata(); return $results; } … Read more
You can create the shortcode as a string like this : $rate = 2587.36; $code = “[mycred_exchange from=\”mycred_default\” to=\”mycred_usd\” min=\”0.00001\” rate=\”$rate\”]”; and then, to execute the code echo do_shortcode($code);
Don’t use a hyphen in the shortcode name. See https://codex.wordpress.org/Shortcode_API#Hyphens .
add_shortcode( ‘type_portfolio’, function( $atts, $content = null ){ $atts = shortcode_atts( array( ‘column’ => ‘3’, ‘category’ => ‘0’, ‘ppp’ => -1 ), $atts); extract($atts); $args = array( ‘posts_per_page’ => $ppp, ‘post_type’ => ‘fen_portfolio’ ); if( $category > ‘0’ ){ $args[‘tax_query’] = array( array( ‘posts_per_page’ => -1, ‘taxonomy’ => ‘cat_portfolio’, ‘field’ => ‘term_id’, ‘terms’ => $category … Read more
You have the posts_per_page attribute in your shortcode, but you’re not actually calling it in your WP_Query. Your’re doing a few unnecessary things in your code, but for now, the issue at hand is that you need to add: if( !empty( $posts_per_page )) { $query .= ‘&posts_per_page=”.$posts_per_page; } Before you call: $wp_query->query($query); As it is … Read more
Here’s the SQL query: $simplelist = $wpdb->get_results(“SELECT `Row1`, `Row2` FROM `table` WHERE `Row1` = ” . $atts[text] . ” ORDER BY `Row1` ASC”); Lets pretend we’re the computer and run it in our heads, and the first thing that happens is: $atts[text] // fatal error! text isn’t defined, you’re missing quotes, but lets fix that … Read more