Add user ID to woocommerce customer dashboard

WooCommerce doesn’t provide any such hook to display User ID on the dashbaord. But you can add it by overwriting dashboard template into your theme file. You can view in brief of how to overwrite templates from below WooCommerce reference link. https://docs.woocommerce.com/document/template-structure/ You need to copy template dashboard.php file from WooCommerce plugin template to woocommerce/myaccount/ … Read more

Getting content from a referenced post

Function get_the_content doesn’t take post_ID as param. It has 2 params: $more_link_text – (string) (optional) Content for when there is more text. $stripteaser – (boolean) (optional) Strip teaser content before the more text. So you can’t use it as in your code get_the_content( $p->ID ); – this will get content of current post and use … Read more

Email address not displaying where I expect it to

This is wrong: $emailaddress = the_author_meta(‘user_email’,$author_id); the_author_meta() will output the value as soon as it’s run, which is above everything else. If you want to put the value into a variable to echo later you should use get_the_author_meta(): $emailaddress = get_the_author_meta(‘user_email’,$author_id); The convention in WordPress is for functions beginning with get_ to return the value, … Read more

Changing the_posts_navigation() html output

This function use the get_the_posts_navigation() to change the text Older posts and Newer posts you can pass array with the args. See this example with the default values: the_posts_navigation( array( ‘prev_text’ => __(‘Older posts’, ‘theme_textdomain’), ‘next_text’ => __(‘Newer posts’, ‘theme_textdomain’), ‘screen_reader_text’ => __(‘Posts navigation’, ‘theme_textdomain’) ) );

Inject class in body when particular page template is used

there is a filter for that and it’s called… body_class 😉 This should work for your case: function add_my_custom_body_class( $classes ) { if ( is_page_template( ‘page-customer.php’ ) ) { $classes[] = ‘body_customer’; } return $classes; } add_filter( ‘body_class’, ‘add_my_custom_body_class’, 10, 1 ); if you wanna add class based on page ID (as you’ve mentioned in … Read more

Copyright info change – Corporate Plus Theme PHP [closed]

Both functions check if the function corporate_plus_footer() exists. If not, one is defined. Without going deeper into hooks and filters, you can simply declare your own corporate_plus_footer() and the other won’t get loaded. Add this to your functions.php function corporate_plus_footer() { echo ‘it works’; } No additional add_action() or similar. Just this function in your … Read more

How to get Post Type from the functions.php file

You have to create the function and call it when post ID is already set. Otherwise it will be empty. E.g. wp_head meets this requirement, init is too early. function my_selective_wpautop() { global $post; if( is_singular() ) { if( ‘page’ == $post->post_type ) { remove_filter( ‘the_content’, ‘wpautop’ ); } elseif ( ‘post’ == $post->post_type ) … Read more

Inline style to PHP [closed]

Why not add a CSS class to the H1? echo ‘<h1 class=”custom-style”>’ . get_the_title() . ‘</h1>’; then in your child theme or custom CSS, apply the style to that class: h1.custom-style { text-align:center; color:#fff; font-size:60px; }

get href content [closed]

I find the DOMDocument() class handles this elegantly. This snippet of code should help you (put the entire html tag including the div wrapper in the $tag variable): $d = new DOMDocument(); $d->loadHTML($tag); $a = $d->getElementByTagName(‘a’); $href = $a->item(0)->getAttribute(‘href’); The $hrefvariable will have the attribute value of href.