Tag Info

Hot answers tagged

3

If your entire page fits in the 4GB LONGTEXT post content field, the limit to the number of pages would be related to the amount of RAM available on your server. When a multipage post is loaded, it is exploded on <!--nextpage--> to put your post into an array of individual pages, so at that point your single page load is consuming at least twice the ...


3

Welcome the the WordPress Stack Exchange and congrats on your first post! First off, you may not want to use query_posts() here. Second off - the_post() needs to be before the_title() as it sets up all the posts functions such as the_title(), the_permalink() etc. and queues the next post in your while loop. Your Loop should look like this: <?php ...


2

The multipage setting is not something that happen via a query, it is handled only via global variables, inside the setup_postdata() function. The only thing you need is to increment a global variable and add your static function using the 'the_post' hook that is fired at the end of that functions. Something like: add_action('the_post', function(WP_Post ...


2

get_the_term_list() will not work here. The best function to use would be wp_get_post_terms() With the following assumption, this can work If a post only belongs to one parent, one child and/or one grandchild, you can order the terms by term_id. It is widely accepted that the parent will have a lower numbered ID than the child and the child will have a ...


2

The custom properties you refer to are dates which a stored in a custom table, and which are joined onto the query for events. At this point in time, when querying events, this table is only joined when only the 'event' post type is being queried. That is, you can search for events - but the dates are only pulled in if you are searching only for events. ...


2

include the conditional tag is_paged() within your if statement; example: if ( $i == 1 && !is_paged() ) :


2

WordPress is strongly opinionated about using absolute URLs. Doesn't mean it's better but it's a choice is makes. The common way to handle it is replace as necessary in database. Please note that if you run replacement on all of database it is extremely important to use serialize–aware tool, or you risk corrupting the data.


2

I usually use tool like this: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ This takes care of any serialized data and can be used to change out staging data from the entire database, not just the post content. Typically a search and replace will look like this: find = staging.site.com and replace with = www.site.com. This ...


2

If the line breaks exist in the database, you just need to run your custom field output through wpautop(). Changes double line-breaks in the text into HTML paragraphs (<p>...</p>). If that doesn't work, then the line breaks probably are getting stripped before going into the database. In that case you'll need to share the code that saves ...


1

If you know the image's ID : wp_get_attachment_image( $image->ID, array(200, 112) ); returns an HTML img element or empty string on failure. The entire code could be something like : <a href="<?= get_attachment_link( '5435' ); ?>"> <?= wp_get_attachment_image( '5435', array(200, 112) ); ?> </a>


1

You may also want to remove the meta boxes from the Post Creation page // REMOVE POST META BOXES function remove_my_post_metaboxes() { remove_meta_box( 'categorydiv','post','normal' ); // Categories Metabox remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // Tags Metabox } add_action('admin_menu','remove_my_post_metaboxes');


1

By using wp_get_attachment_image_src() function get the original url of thumbnail if ( has_post_thumbnail() ) { $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $image = $image_url[0]; } Then add Image Url to your custom code <a href="<?php echo $image; ?>"><img class="alignright size-medium ...


1

Use WP CLI! First grab the posts you want, we'll use the wp post list command, and we need to run the command in our WordPress directory on the server. Here I'm grabbing all posts in October 2014 on my blog: wp post list --year=2014 --monthnum=10 This gives me ( oh noes my secret draft posts ): ...


1

You typed "mobiles" when you said you wanted to check for post type "mobile". So simply remove the s ;). <? if( post_type_exists( 'mobiles' ) ) { echo 'The Products post type exists';} ?> Should be: <? if( post_type_exists( 'mobile' ) ) { echo 'The Mobile post type exists';} ?> If it's still not working, triple check if you ...


1

The function you are using, get_most_recent_post_of_user, won't work as it only retrieves the latest post from the author. It cannot retieve a list of posts Walks through each of a user's blogs to find the post with the most recent post_date_gmt. You will most probably be better of using either WP_Query or get_posts to achieve this. You should first ...


1

You can use the pre_get_posts action to set posts_per_page to -1 on the monthly archive pages. I said wrongly in a comment to use is_archive() as your conditional. The problem with is_archive() is, it returns true on all archives, which includes category and taxonomy archive pages as well. I would suggest to make use of is_date() and is_month() if you ...


1

Just use the public API functions: has_shortcode( $content, $tag );. It uses shortcode_exists( $shortcode ); internally to search the global $shortcode_tags array for the shortcode you are searching for. If that is successful, it uses get_shortcode_regex() to search for the actual shortcode - this will save you quite some time and avoid mistakes. ...


1

Having spent 50 minutes unsuccessfully explaining accepted answer to colleague... I want to point out that for simple case the basic check of post count might be perfectly sufficient to template such output: if ( 6 > $wp_query->post_count ) { // placeholder output }



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