spliting posts into two columns

You could always try to create 2 arrays of titles, say $left and $right, $odd and $even, or $tom and $jerry, and fill them with the titles during your loop, and print them after the loop has ended like so: Create array $left = $right = array(); Then unleash your loop [edited the below to … Read more

Shortcode to generate and save password in a file

Per the comment under the OP’s question, below is the solution by using a return instead of an echo: add_shortcode( ‘phptest’, ‘custom_shortcode_phptest’ ); function custom_shortcode_phptest() { // Add Shortcode function generatePassword( $length = 6 ) { $characters=”0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”; $charactersLength = strlen( $characters ); $pass=””; for ( $i = 0; $i < $length; $i++ ) { $pass … Read more

Return array of categories to php function for current post

EDITS: <div id=”job-manager-job-dashboard”> <h3><?php _e( ‘Job listings are shown in the table below.’, ‘wp-job-manager’ ); ?></h3> <table class=”job-manager-jobs”> <thead> <tr> <?php foreach ( $job_dashboard_columns as $key => $column ) : ?> <th class=”<?php echo esc_attr( $key ); ?>”><?php echo esc_html( $column ); ?></th> <?php endforeach; ?> </tr> </thead> <tbody> <?php if ( ! $jobs ) … Read more

Proper use of internationalization

The two are exactly the same but I would go for the first one: Easier to read No interpolation, keep interpolation for variables And, including the tags inside the format is making things more complicated, I can think of designers being tempted to use more tags if they see you are using them.

echo CHILD / SUB CATEGORIES of the CURRENT CATEGORY only

Your code loops through all top level categories, then shows all child categories of each one, so I’m not surprised it’s showing all child cats! If you want to show the child terms of the current category (i.e. on a category archive?), use: $current_cat_id = get_queried_object_id(); $kids = get_terms([ ‘taxonomy’ => get_queried_object()->taxonomy, ‘parent’ => $current_cat_id, … Read more

Add a plugin before main container

it looks like you’re using shortcode to execute your plugin. so instead of just echo ‘[plugin id=”1″]’; use this: echo do_shortcode(‘[plugin id=”1″]’); put this in the php file where you want it to load. For example, right above the <div id=”content”> this can be in whatever file you wish to execute the shortcode

Customizer Show/Hide

get_theme_mod() has a second parameter where you can set the default value, the value to use if the option is not set. So, if the default value is “1”, you can use: get_theme_mod( ‘display_header_image_title’, ‘1’ ) Then, if there is not value for display_header_image_title (no value in database), “1” is used. So, you could check … Read more