Logic to Print/echo a css class only for 1st post and ignore all post after 1st? [closed]

As I noted in the comments, this is more a programming language question than a WordPress Development question, and that goes for the second question, too. However, instead of adding to comment discussion and making more mistakes, I’ll write out an answer. function slider_news() { $num = 0; $args = array( ‘numberposts’ => 3 ); … Read more

add filter not working when cancatenating variables

Look at your filter: apply_filters(‘change_number_of_posts_home’, $posts_per_page) The value being passed to it is $posts_per_page, so of course they can’t change $number. If you want only the number to be filtered then that’s the part that should have the filter applied: $number = apply_filters(‘change_number_of_posts_home’, 3 ); Then the query can just look like this: $wp_query->query( ‘post_per_page=” … Read more

How to Globally Use wp_localize_script() Ajax URL

You can conditionally echo the code on only few templates or specific pages. Here is an example: add_action ( ‘wp_head’, ‘my_js_variables’ ); function my_js_variables(){ // for specific page templates $current_template = get_page_template(); // return if there is no page template, or if the page template is other than template-x1.php or template-x2.php if( !isset($current_template) || ( … Read more

How to use thumbnails in gallery?

There is a project going on about the image sizes. You can follow it right here. Right now, you can try using shortcode_atts_gallery filter. Take a look at these codes to get a hint: /* Register shortcode_atts_gallery filter callback */ add_filter( ‘shortcode_atts_gallery’, ‘meks_gallery_atts’, 10, 3 ); /* Change attributes of wp gallery to modify image … Read more

What allows a template file from plugin to be copied in child theme and overridden?

My first question is, what is the function or loader that makes this happen? And secondly, is this a global WordPress feature, or do plugin developers have to build this functionality into the plugin? It’s not a WordPress feature. Not exactly. Each plugin that does this has created their own function for loading template files … Read more

How to customize save function event?

WordPress fires a number of different hooks when a post is (published / updated / saved). It’s usually best to browse through the Codex to determine which hook fires when, and only when, you want to run your custom code. It’s important to be aware that some of these hooks fire multiple times when you … Read more

Check if user has enrolled in Sensei LMS Course on Lesson Page

You can show enrolment status on the lesson page using sensei actions and function. you can display status before/after content using action. just use proper action and paste code in active theme’s functions.php file. To display before Lesson content use below action: add_action(‘sensei_single_lesson_content_inside_before’,’sensei_single_lesson_content_callback’,100); To display after Lesson content use below action: add_action(‘sensei_single_lesson_content_inside_after’,’sensei_single_lesson_content_callback’,100); Here is function … Read more