How i can put $_GET codes in function.php?

function custom_function_redirect() { if ( isset( $_GET[ ‘link’ ] ) && $_GET[ ‘link’ ] != ” ) { wp_redirect( $_GET[ ‘link’ ], 301 ); }else{ die(‘test’); } } add_action(‘template_redirect’,’custom_function_redirect’); Try this it worked for me. For redirection you should hook the function in template_redirect

Autogenerate a Table of Contents

Sure. In your single.php or where you loop through the posts, start by getting the content: $content = get_the_content(); Then use a regex where you target anything within <h2> tags: $regex = ‘/<h2>(.*?)\<\/h2>/u’; And then use preg_match_all() to find all titles: preg_match_all($regex, $content, $table_of_content); This will create a multidimensional array, see: print_r($table_of_content); So you have … Read more

Print Dashboard submenu name and filename

If you want them in an unordered list: echo “<ul>\r\n”; foreach ( $submenu as $group => $item ) { foreach ( $submenu[$group] as $key => $value ) { echo “<li>” . $submenu[$group][$key][0] . ” > ” . $submenu[$group][$key][2] . “</li>\r\n”; } } echo “</ul>”; This results in: <ul> <li>Home > index.php</li> <li>Updates > update-core.php</li> <li>Library … Read more

Not all CSS elements transferring via parent to child?

good question! Basically, in your enqueue you call the Parent stylesheet first then the child, so any child styles (by definition of css specificity) will override the parent styles. Code example from the WordPress codex: https://codex.wordpress.org/Child_Themes <?php function my_theme_enqueue_styles() { $parent_style=”parent-style”; // This is ‘twentyfifteen-style’ for the Twenty Fifteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ … Read more

How to call multiple functions from multiple files into a WordPress page template [closed]

Just add your functions to your theme’s functions.php file. They will be available to all of the templates within the theme. functions.php: function add_cars_specifications() { if ( in_category( ‘cars’ ) ) { echo types_render_field( ‘cars-specs’, array() ); } } In your page template file and other templates in the theme, add_cars_specifications() will be in scope, … Read more

echo custom fields with AJAX

I’m not sure Why you used loop to display your post meta. and you code are all ok but you have to change little-bit. Q. Why you used inline script ? On my opinion you should used external script file to do this. anyway that’s not the main issue here. In order to work with … Read more

wp_nonce_field is breaking form for reasons unknown

wp_nonce_field() will echo its output by default, so set the $echo parameter to false: add_shortcode(‘signup_form’, ‘get_signup_form’); function get_signup_form() { $wp_nonce_code = wp_nonce_field( -1, ‘_wpnonce’, true, false ); $signup_form_code = <<<EOT <form method=”post” class=”popup-register” action=”/my-account/”> <p style=”text-align:center;”> <input type=”email” class=”popup-input” style=”width: 65%;” name=”email” id=”reg_email” placeholder=”Enter your email address”> <input type=”submit” class=”popup-input-submit button” style=”margin: 0; border: 1px … Read more