Display selected categories onto post page

If what I understand from your question is correct. You have a post that categorized in multiple categories and subcategories. I have already made the same in a website. use these following code bellow so a sub categories will displayed after the parent category. //first part $allcats = get_the_category(); $parent_id = $all_ids = array(); foreach … Read more

WordPress post next/prev not working

I made some updates in your code. Please, try this updated version. <div id=”demo”> <?php $wp_query = new WP_Query( array( ‘category_name’ => ‘Case Study’, ‘posts_per_page’ => 1, )); ?> <?php if ( $wp_query->have_posts() ) : ?> <?php while ( $wp_query->have_posts() ) : the_post(); ?> <?php the_title(); ?> <?php the_content(); ?> <?php endwhile; ?> <div class=”nav-previous … Read more

Get post by tag

Look at this section: Tag parameters in WP Codex, where is explained search by tags. Your code like right. Try change numberposts to int: <?php $args = array( ‘numberposts’ => 3, ‘post_status’ => ‘publish’, ‘tag’ => ‘travel’ );

Update all posts in a loop everyday

Yes, WordPress has a cron system called WP Cron (which is not the same as a *nix cron). The idea is that your plugin would register a task (a WordPress action callback) that performs the desired logic (in your case, running the code that updates all the posts).

Count the number of a post types associated with another post type

Sounds like you need to use WP_Query or something similar. <?php // First query: get all destinations $args = array( ‘post_type’ => ‘destination’, ‘posts_per_page’ => -1, ‘no_found_rows’ => ‘true’ // skips pagination ); $destinations = new WP_Query($args); // Now for every destination: foreach($destinations as $destination) { // Second query to get tours $secondargs = array( … Read more

Auto delete posts based on content text

If you’re comfortable using phpMyAdmin, you can run this query: DELETE FROM wp_posts WHERE post_content LIKE “%A line of same text that should be deleted%” Replace with the text you’re wanting to remove, but keep the “% %” symbols. The percent symbols mean to search for that string anywhere inside the post content – even … Read more

Posts and Pages: 404 Page not found

Did you try to re-save Permalinks? Navigate to: WordPress Dashboard > Settings > Permalinks: Click “Save Changes” and then click on the link of the page that should work from the “Edit Page” of that page. Also review Permalinks settings if they are correct. If it still doesn’t work, you can try to debug the … Read more

Post is blank when I click on the link

Your site puts quotes in the permalink structure. Find out where these things come from. Without these quotes it appears to work. http://fohh.vavee.com/2017/06/24/harmony-hall-launches-10th-anniversary-celebration/ A temporary VERY dirty solution is to filter the quotes out of the global $content variable.

Is it possible to automatically publish a post once a woo-commerce product is published?

WC products are posts themselves, so you could use: add_action(‘publish_post’, ‘wpse_publish_post_with_product’); Within the new function, you’d have a check for post_type. If the post_type that was just published is a WC product, then grab the image and description from that post, and use wp_insert_post() to publish a Post with the same info. Side note: I’m … Read more

How include css class based on post ( in loop ) slug?

The error you get is produced by $slug = get_post( $post )->post_name; because there is no post_name on a 404 page. So, to prevent this error you must structure the function in a way it doesn’t get to this line when it is called on a 404-page. Like this: add_filter (‘post_class’, ‘fl_pages_bodyclass’); add_filter (‘body_class’, ‘fl_pages_bodyclass’); … Read more