Delete post after x minutes if user role is

This is a simple question, but it involves quite some work, so I’ll just give you an outline: First, you need to define a cron job that runs every minute or so. This will allow you to define an action that is run automatically. Beware that this will run only when the site is visited, … Read more

Is it possible to customize the post according to post format in single.php?

Yes, it is possible. The easiest and very readable way would be to do this like TwentyX themes do – using get_post_format and get_template_part functions. Let’s say that your current single.php file looks something like this: <?php get_header(); ?> … <?php while ( have_posts() ) : the_post; ?> <article …> … </article> <?php endwhile; ?> … Read more

Fixing paragraph spacing in posts

You can add the following code in your CSS. (Considering that you are using h1) h1 { padding-top: 5px; } You can see / play with the same sample on https://codepen.io/ankyit/pen/NzRjrL

Get Post’s first image using Short-code

I would rewrite a simple shortcode to retrieve only post images: add_shortcode( “postImages”, “stack_309224_attachhment” ); function stack_309224_attachhment($atts){ extract(shortcode_atts( array( ‘id’ => 1, // default id of the post “max” =>4 ,// default max number of images to display “featured”=>”false” // if to retrieve the post featured image or not, default false ), $atts )); ob_start(); … Read more

How to create wordpress class with post meta? [closed]

Can you try this. This should work. You don’t need to use construct if you call getDatain your theme files. You key need to be static value. After that you can call it like self::$key Use like this : echo $theme->getData(get_the_ID()); inform me if code works 🙂 <?php class themeSettings { private static $key= ‘themeSettings’; … Read more

Show post content and title in diferent divs using WP_Query using a loop

PHP loops are loops – you can control them 😉 <?php $the_query = new WP_Query( array(‘posts_per_page’ => 4) ); if ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class=”grid”> <div class=”main post”> <!–show data of the first post in the array–> <?php the_title(); ?> <?php the_content(); ?> </div> <div class=”nested”> <?php while ( $the_query->have_posts() ) : … Read more

Delete all drafts?

draft is not a post_type, it’s a post_status. So you should use your second block of code with that substitution: DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_status=”draft”