Downloadable Documents

No need to insert the download into the post as @kaiser says, you can automate: $download = get_children( ‘post_type=attachment&post_mime_type=application/pdf&post_parent=”.$post->ID ); if ($download) { foreach ( $download as $attachment_id => $attachment ) { echo “<a href=”‘.wp_get_attachment_url($attachment_id).'” target=”_blank” class=”download”>Download PDF</a>’; } }

Display posts by tag on page

This should do the job. It’ll check for posts that have been tagged with the title of the current page. There’s no need to use if (have_posts()): on a page template: if the template is called it will be because there is a post 🙂 <div class=”page-loop”> <?php while (have_posts()) : the_post(); $page_title = strtolower(get_the_title()); … Read more

Get names of authors who have edited a post

The WordPress function get_the_modified_author() will give you the author who last edited the current post. But if you want to list all the users that have edit the current post, you could try: function get_the_modified_authors_wpse_99226(){ global $wpdb; $authors = array(); $results = $wpdb->get_results( $wpdb->prepare(“SELECT post_author FROM $wpdb->posts WHERE (post_type=”%s” AND ID = %d) OR (post_type=”revision” … Read more

Getting Position of a post in a category

If I understand well, you need to retrieve all the posts having category ‘y’ and also meta key ‘facebook_shares’, after that, you need the position of a specific post. My proposal is: Create a class that extends WP_Query and filter the results for required category and meta field. This class should also filter the SQL … Read more

How can you make sure authors’ posts are longer than 250 words?

Prevent authors from publishing too short content: Here’s one idea using a custom post status, for example short: /** * Register a custom ‘short’ post status * * @see http://wordpress.stackexchange.com/a/159044/26350 */ function wpse_short_post_status() { register_post_status( ‘short’, array( ‘label’ => _x( ‘Short’, ‘post’ ), ‘public’ => false, ‘exclude_from_search’ => true, ‘show_in_admin_all_list’ => true, ‘show_in_admin_status_list’ => true, … Read more

How do you get all the urls of images attached to a post?

You need to loop through the attachments within your post loop, replace the section of code you posted with this (put this together from some other code I found related to a similar problem, but couldn’t test it): </BasicDetails> <?php $args = array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, // show all … Read more

Plain-text tag list?

You can play with arguments to only fetch what you need and get rid of loop: $classes = implode(‘ ‘, wp_get_post_tags( get_the_ID(), array(‘fields’ => ‘names’) ) );

Query posts from current year

You just need get current date and add it on data_query in wp_query, Look this: <?php $getdate = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $getdate[“year”] ), ), ); $query = new WP_Query( $args ); ?> and then use loop: <?php if ( $query->have_posts() ): while ( $query->have_posts() ) : $query->the_post(); the_title(); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)