Tag Info

Hot answers tagged

3

'the_posts' is an action fired everytime WP_Query get posts, for main query and for other secondary queries, so when you do something like: $foo = new WP_Query($args); in a widget or elsewhere (shortcode, related posts...) 'the_posts' is triggered again. However there is only one main query, so you can use a conditional and do what you do only if the ...


3

It won't be very hard to do. Just add this to your functions.php or into your plugin: function my_edit_per_page( $result, $option, $user ) { if ( (int)$result < 1 ) return 20; // or whatever you want } add_filter( 'get_user_option_edit_page_per_page', 'my_edit_per_page', 10, 3 ); // for pages add_filter( 'get_user_option_edit_post_per_page', ...


2

Don't use the publish date as the event date. Save the event's date in a custom field in the format yyyy-mm-dd, and use a meta query to order events by that date. Also see pre_get_posts for ordering events correctly on archive pages without running a new query.


2

There are no methods the_content() or the_title() of your query object. These: $review_query->the_content(); $review_query->the_title(); should just be the_content(); the_title(); If you had debugging enabled you would see an error informing you of this.


2

<?php $previous_post=null; if ( have_posts() ) { while ( have_posts() ) { the_post(); global $post; if($previous_post!=null) { /// Do what ever you want to do with previous post $previous_post. } $description = get_post_meta( get_the_ID( ), ...


2

When a post is saved, all the data is saved in the database, and a unique ID is assigned to that specific post. All information and attachments for that post is also linked to the post's unique ID. This ID will never change, this post will forever have this ID. The post keeps this ID until the post is PERMANENTLY deleted


2

No they don't change, but you shouldn't rely on them for external sites. If we're talking about purely in the database on an individual WordPress site, then: If it's a published/established post/page then yes, the ID will not change other than to delete it If its a revision, a draft, etc the ID won't change, but it won't survive for very long either. It ...


2

What you are doing is the safe way, and the way I'd recommend. To my knowledge, there is no Core function to bulk update only single values in the $wpdb->posts table, so to do that you'd need to write your own SQL... $ids = array(); // your IDs; I am assuming these to be validated and sanitized $wpdb->query("UPDATE {$wpdb->posts} SET post_status = ...


2

What about something like that? function wpse139657_orderby(){ if( isset($_GET['orderby']) ){ $order = $_GET['order'] or 'DESC'; set_query_var('orderby', 'meta_value_num'); set_query_var('meta_key', $_GET['orderby']); set_query_var('order', $order); } } add_filter('pre_get_posts','wpse139657_orderby'); In this way ...


2

You can use a filter to pre_get_posts so that only your posts are listed. Something like this: function my_posts_only( $query ) { global $pagenow; if ( 'edit.php' != $pagenow || ! $query->is_admin ) return $query; if ( ! current_user_can( 'manage_options' ) ) { global $user_ID; $query->set( 'author', $user_ID ); ...


2

In your example, you can't. Per the Codex, [is_single()] checks if a single post of any post type except attachment and page post types is being displayed. You're trying to use it on the transition_post_status hook, which is not related to page display, and so is_single() has no meaning. The Solution Instead of using is_single(), use ...


2

If you hook your localize script function to wp_enqueue_scripts, then you will have access to the global $post variable. As long as you pick a hook at or after 'wp' you should have access to the global $post. <?php add_action('wp_enqueue_scripts', 'YOUR_NAME_scripts'); function YOUR_NAME_scripts() { wp_enqueue_script('YOUR_NAME-js'); ...


1

I imagine tagging a post has as much of a impact as the keywords meta tag, which is not at all. Mostly because you can easily cram your post full of unrelated keywords to try and trick the web crawler(s) into marking your content under many different 'categories'. They're mostly for your user and your (built in) search. The best kind of SEO is creating good ...


1

If your first query works you can try something like this : function get_post_by_id($id){ $content = array(); foreach ($id as $key => $value) { $post_content = get_post($value); $content[]=$post_content->post_content; } return $content; } Cheers, phpbits


1

Install metabox plugin and active: /**** Add this code in your function.php ****/ $meta_boxes[] = array( 'id' => 'post_sidebar', 'title' => 'post Sidebar', 'pages' => array('post'), 'priority' => 'low', 'fields' => array( array( 'name' => 'Post ...


1

Custom fields or post meta entries can be hidden from the by default in Wordpress available »Cutom Fields«-Metabox by prefixing them with a underscore - _ - as noted here. As addition, if you want hidden fields to be visible during development you can do that easily - take a look at this answer to know how.


1

You should remove the link from the anchor tag: <a class="button" href="#" style="background-color:white;color:black;"> <strong>Submit</strong> </a> Then your jQuery part should be: $('a.button').click(function(event){ event.preventDefault(); //your ajax gets here: jQuery.ajax({ type:"post", ...


1

If you poke through WP_Query the set of queried posts is saved into posts property and current post gets assigned to post one (each time loop iterates). So you could do $connected->posts[0] if you need to just fetch that, but it might be more convenient to do $connected->the_post(); then $connected->post if you need to skip first one and process ...


1

I think you're making this far more difficult on yourself than you need to. Easiest Solution First, I'm a bit confused, because the page you call the "blog page" is not actually the blog page. The blog page is the blog posts index page, and the page you've linked is actually the category archive index for category ID 7. If you really want this: ...


1

My best educated guess is to perform a checklist on the following: Take a look at the virtual host configuration files for your domains, if you have access to them. Ensure that they agree with the corresponding WordPress installations on your machine(s). If your Virtual Host configurations are written correctly and as intended, then the next step is to ...


1

I am working on something similar. This is for a podcast upload meta-box. Returns the url to the file. Here is what I have so far: /*******************************************************Podcast Meta-boxes *******************/ //Add Metabox add_action( 'add_meta_boxes', 'add_upload_file_metaboxes' ); function add_upload_file_metaboxes() { ...


1

add_filter( 'the_posts', 'wpse138563_add_posts' ); function wpse138563_add_posts( $posts ) { if( ! is_multisite() ) { // if we're not using Multisite, bail return; } if( is_main_site() ) { // if we're in the root site, bail return; } $country = get_bloginfo( 'name' ); // This assumes that the categories ...


1

I haven't tried the Gravity Forms plugin but if you are using the wp_insert_post function to insert the new post, you just use 'post_excerpt'. example: $new_post = array( 'post_title' => 'Post Title', 'post_content' => 'Post Content', 'post_status' => 'publish', 'post_excerpt' => $custom_excerpt_field ); ...


1

As far as I know, you should be able to include the following code in your theme file somewhere. You would need to upload the appropriate icons. //Facebook Share <a href="http://www.facebook.com/sharer/sharer.php?s=100&p[url]=<?php echo get_permalink() . '&p[title]=' . get_the_title(); ?>"><img src="[facebook icon url]" ...


1

Here is a solution that uses genericons. First, download and intall the genericon pack in your theme. Enqueue the genericon stylesheet function enqueue_genericon_style() { wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.0.2' ); } add_action( 'wp_enqueue_scripts', 'enqueue_genericon_style' ); ...


1

Well, yes, of course. Take a look at this reference: http://codex.wordpress.org/Function_Reference/previous_post_link http://codex.wordpress.org/Function_Reference/next_post_link You can customize it however you like, so you can simply put an html image tag in there. The function must be used in the loop to work. I'd do it like this: <?php ...


1

I found a nice snippet at this site for your functions.php that does the trick: add_shortcode( 'gallery', 'file_gallery_shortcode' ); function file_gallery_shortcode( $atts ) { $atts['link'] = 'file'; return gallery_shortcode( $atts ); } I'd actually been looking unsuccessfully for the same thing, so I'm glad you asked.


1

Here is a start. Create a template called content-related.php Inside that paste the following code <?php /** * The default template for displaying realted posts * * @package WordPress * @subpackage Pieter Goosen * @since pietergoosen 1.0 */ wp_reset_postdata(); global $post; // Define shared post arguments $categories = ...


1

Have not tested it but this should get you to your goal. I believe Accore LTD has it correct as well, except your slide #s will be post ID, instead of slide-1, slide-2 <div class="content"> <?php if ( have_posts() ) : ?> <h2><?php single_cat_title('',true); ?></h2> <div> <ul> <?php $inc = 1; ...


1

Just an addiction to @KrzysiekDróżdż answer. When viewing a specific post status the url query string variable 'post_status', is set to the name of the status, so you can use $_GET['post_status'] to narrow the effect of @KrzysiekDróżdż code only for pending posts: function my_edit_per_page( $result, $option, $user ) { $status = filter_input( INPUT_GET, ...



Only top voted, non community-wiki answers of a minimum length are eligible