Redirect to other page if login

Add below code in your functions.php file of active theme directory in order to restrict the login page to logged-in users and redirect them to core user page (user profile). You can replace “um_get_core_page( ‘user’ )” with any page URL where you want to redirect logged-in users. /* Restrict Login page to logged-in users and … Read more

Run shortcode in custom script in wp_head if post type is CPT ‘Jobs’

You shouldn’t do it in a shortcode, you should enqueue this particular JavaScript file only for the page you want. Place something like this in your functions.php: function my_custom_scripts() { if( is_singular(‘job’) ){ wp_enqueue_script(‘jobpostingschema’, get_stylesheet_directory_uri() . ‘/js/jobpostingschema.js’, array(), ”, false); } } add_action(‘wp_enqueue_scripts’, ‘my_custom_scripts’);

Get user custom field value on function.php

EDIT I think the solution given by @dboris may work. Alternatively you could try to hook your email sending after the user registration like this global $uID; //to keep the value to reuse it later, null at this step function mailInscriptionSecteurRhone() { global $uID; $user_ID = $uID; $headers = array(‘Content-Type: text/html; charset=UTF-8’); $candidat = get_userdata( … Read more

Add attribute only to first image of every post via functions.php

add_filter( ‘the_content’, ‘wpse317670_add_img_attribute’ ); function wpse317670_add_img_attribute( $content ) { $from = “https://wordpress.stackexchange.com/”.preg_quote(‘<img’, “https://wordpress.stackexchange.com/”).”https://wordpress.stackexchange.com/”; $to = ‘<img example=”example”‘; return preg_replace($from, $to, $content, 1); } This will add the example=”example” to the first image found in every post content. There is another option, without using regular expression (possibly much faster and will use less memory): add_filter( ‘the_content’, … Read more

Template Loop – add switch case php

if ( $query->have_posts() ) : ?> <ul id=”list-con”> <?php while ($query->have_posts()) : $query->the_post(); ?> <?php switch ( get_post_type( $post->ID ) ) { case “firstcase”: ?> <li>code as defined above</li> <?php break; case “secondcase”: ?> <li>another code as defined above</li> <?php break; } ?> <?php endwhile; ?> </ul> <?php endif;

Co-Authors Plus: How do I get all authors with a query?

If you are using Co-Authors Plus plugin. By default, it will show the original author of the post. You’ll need to edit theme files with the code responsible for showing the author name for posts. This could be single.php, content.php, or a template tag in your theme’s functions.php file. the_author_posts_link() and you will need to … Read more

how to change “posted by” words

This can MOST LIKELY be done with the get_text filter. Here’s an example (and then some caveats): function my_theme_text_switcher( $translations, $text, $domain ) { if ( $domain == ‘my-theme’ && $text == ‘posted by’ ) { $translations = __( ‘YOUR TEXT HERE’, ‘my-theme’ ); } if ( $domain == ‘my-theme’ && $translations == ‘on’ ) … Read more

Cant display an image via PHP in wordpress

I think that you need echo the image, try this: <php $image = wp_get_attachment_image_src( $post_thumbnail_id ); //echo( $image[0] ); ?> <img src=”https://wordpress.stackexchange.com/questions/319794/<?php echo $image[0]; ?>” alt=””>

How can I pass a shortcode value to the head in wordpress functions.php

Shortcodes, as I understand them, are to be used inside content of pages/posts, and (with 4.9) widgets. They aren’t supported inside other spots on the page, only in the page/post/widget content. From the Codex: https://codex.wordpress.org/Shortcode [WP] only expands the shortcodes within the content of a Post, Page, or custom post type. But I don’t think … Read more