Adding Custom Body Class for Page: Shop

you could try to use this: add_filter(‘body_class’, ‘custom_body_class’); function custom_body_class($classes) { global $post; if ($post->ID == 346) { $classes[] = ‘services’; } return $classes; } This can be used anywhere as its pulling the global variable first.

How to center all text body in single.php at once?

There is probably some CSS you can add via Additional CSS (in Theme CUstomization) that you could use. Use the Inspector tool of your browser (F12) to see the CSS ‘class’ element used in the content. If the class is called ‘the_content’, then add this to your Additional CSS: .the_content{text-align:center !important;} You might need this, … Read more

modifying every other element’s class inside while loop

<?php $homePosts = new WP_Query(array( ‘posts_per_page’ => 5 )); $count = 1; while ($homePosts->have_posts()) { $homePosts->the_post(); if ( $count % 2 == 0 ) { $class=”right”; } else { $class=”left”; } ?> <section class=”align-<?php echo $class; ?>” > <div class=”content”> <?php the_title(); ?> <?php the_content(); ?> </div> </section> <?php $count++; } wp_reset_postdata(); ?> You can … Read more

Finding post ID dynamically on click

What you’re looking to accomplish isn’t really pagination. That threw me off initially. You’re building a navigation that will be site-wide. If that’s the case, you can either capture the ID from the url (this is not very performant) or add the ID to the markup. This example shows you how to add the ID … Read more

Reload page with a different shortcode when a user selects from a dropdown

You can create a custom shortcode wrapper that will execute the shortcode with the desired attributes, so you would use [jobs-custom] in the page: add_shortcode(‘jobs-custom’, ‘custom_jobs_shortcode’); function custom_jobs_shortcode($atts) { if (is_user_logged_in()) { $per_page = get_user_meta(get_current_user_id(), ‘jobs-per-page’, true); } if (!isset($per_page) || !$per_page) { if (isset($_COOKIE[‘jobs-per-page’])) {$per_page = $_COOKIE[‘jobs-per-page’];} else {$per_page = 10;} } return do_shortcode(‘[jobs … Read more