Hot answers tagged

4

I found an other way that works well for me: When initializing the plugin, do not enqueue your scripts and styles, but register them with wp_register_style and wp_register_script. Next you can load the script/style on demand. For example when you render a shortcode with wp_enqueue_style("your_style") and wp_enqueue_script("your_script"). Here is an ...


2

I think the best way here would be to run three separate loops here (you can also do two loops, but then you need to get full posts in the men and women queries, combine them and shuffle them), the first two will be used to get 5 men and the second loop will get 2 women. You can adjust this as necessary. The third loop will use the info from the first two ...


2

I made a few adjustments. Once I created my two arrays, I combined them this way $merged_queries->posts = array_merge( $women->posts, $men->posts ); shuffle($merged_queries->posts); $merged_queries->post_count = $women->post_count + $men->post_count; while ( $merged_queries->have_posts() ) { $merged_queries->the_post(); // do ...


2

Write it out in english and be clear about your logic, aka if you say that X should happen when Y is true, what happens if Y is false? AKA else. If X then Y, else Z If we're on the home page, then do nothing otherwise if the page has a thumbnail then run code that pops the page title on top of full width thumbnail with suitable CSS ...


1

If I understood you correctly: <?php //if home, do nothing if( ! is_home() || ! front_page() ) { //if has post thumbnail if( has_post_thumbnail() ) { the_post_thumbnail( 'full' ); echo '<h1 class="entry-title">'. get_the_title() .'</h1>'; } else { //no post thumbnail, show normal entry ...


1

In a template file, this should do it: <php If (!is_user_logged_in()) { wp_redirect( "start/login" ); exit(); } ?>


1

If I understand you right you just want to use a '?' type of if statement: $output = '<div class="w-blog-entry" style="padding:0;"> <div class="w-blog-entry-h"> <div class="l-subsection color_dark" style="background-image: url('.$the_thumbnail.'); background-position: center center; ...


1

Since you've designated a specific page to be your Post Archive ( blog ) it no longer is a standard page; meaning is_page() will likely fail. Since your blog page is now more of an archive, it is automatically being returned because of your first conditional. is_singular() - Returns true when viewing a single page, post, or post type. So what you're ...


1

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories? As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts ...


1

You should do this in the shortcode/plugin itself. An easy way to do it may be something like this: // if the shortcodes empty: if ( empty( $shortcode_content ) ) { // set a default nothing found message $shortcode_content = 'Sorry! Nothing found'; } return $shortcode_content;


1

Note that did_action only takes one input argument: the name of the action hook. The scope of your if sentence is also unclear. I don't think you want to use did_action at all here, it doesn't give you the number of emails. You can try the following instead: if ( $unread = do_shortcode( '[input-unread]' ) ) printf( "<span class='new ...



Only top voted, non community-wiki answers of a minimum length are eligible