Tag Info

New answers tagged

0

It appears that at some point the plugin Simple Local Avatars broke things. Disabling it solved my problem. I now have a user that I need to find another avatar solution for, as he doesn't have a Gravatar and using his other WordPress blog email address didn't import his photo.


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; ...


0

i found one way. and is showing properly. .but i am not sure is that perfect way or not. please give your suggestion <ul> <?php $test = get_the_title(); $args = array( 'cat_name' => $test ); $args = array_merge( $args , $wp_query->query ); get_posts( $args ); while (have_posts()) { the_post(); ?> <li data-slide="<?php ...


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, ...


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.


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', ...


0

You should be able to use WordPress' built-in post scheduling ability. They have a tutorial on the subject: https://make.wordpress.org/support/user-manual/content/posts/schedule-a-post/


0

You can use wp_trim_words to trim the_content(). Here is a nice small function function wpse_custom_content($limit) { return wp_trim_words(get_the_content(), $limit, '<a href="'. esc_url( get_permalink() ) . '">' . '&nbsp;&hellip;' . __( 'Read more &nbsp;&raquo;', 'wpse' ) . '</a>'); } You can simply just call echo ...


0

Check out the Wordpress Codex reference page for the_excerpt() as it is a built-in way of doing what you're looking to accomplish: http://codex.wordpress.org/Function_Reference/the_excerpt EDIT: it also has an example for shortening the excerpt beyond the default length.


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

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 ...


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

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


0

According to the Codex, you can't do this directly through the API. However, you can do it by using your own quicktags.js file as shown below. function sample_load_admin_scripts() { if ( is_admin() ) { wp_deregister_script('quicktags'); wp_register_script('quicktags', ("/path/to/your/quicktags.js"), false, '', true); } } if (is_admin()) { ...


0

There was some weird issue with how Wordpress was handling line-breaks and auto styling between the shortcodes. After some more playing around was able to eliminate the issue. Very finicky system...


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( ), ...


1

You can use the function get_previous_post() to get the previous post object. $prev = get_previous_post(); if ( !empty( $prev ) ) { // Do some comparing } Hope this helps


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.


0

At first glance, I see that your query is calling for 'post_type' => 'page' while the taxonomy is registered on the post object type. Changing the post type to post ('post_type' => 'post') should fix the problem.


0

You have to know the ID/s of the category/categories you wish to show. Then add 'category' => 'X' in the array. X is the ID of your category. Example: $args = array( 'numberposts' => '5', 'category' => '3' ); or if you wish more then one category: $args = array( 'numberposts' => '5', 'category' => '3,6,7' );


0

You don't need to loop over each category & query them one-by-one, just query them all once: $query = new WP_Query( array( 'post_type' => array( 'service' ), 'category__in' => $ucategory, 'posts_per_page' => -1, ) );


2

You should use Custom Post Type with hierarchical structure, which works same as Pages.


0

Here is my version, keeping all html tags and also trimming the content after the last word in of a sentence if ( ! function_exists( 'pietergoosen_custom_wp_trim_excerpt' ) ) : function pietergoosen_custom_wp_trim_excerpt($pietergoosen_excerpt) { global $post; $raw_excerpt = $pietergoosen_excerpt; if ( '' == $pietergoosen_excerpt ) { ...


0

Change the cat to the category number you want. For example: "cat" => 2, Or if you know the category name you could also use: "category" =>"category_name", You should add any of the above two lines in your wp_query arguments like the one in below which is empty: $wp_query = new WP_Query( array( ...


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 ...


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'); ...


0

Wordpress don't have a function show_content. Content in wordpress is displayd using the_content(). The excerpt is displayd using the_excerpt(). Just a point of note, move your WP_Query outside your if statement and change if ( have_posts() ) to if ( $wp_query->have_posts() )


0

Untested, but I think this will do the trick! <?php // Get date Categories $date_cats = get_categories(array( 'include' => '1,2,3,4' )); // Loop through date categories foreach($date_cats as $date_cat) : // Get link of current date category $date_cat_link = get_category_link( $date_cat->cat_ID ); ?> <ul> ...


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


0

You can simply include a custom search function into your search by using pre_get_posts You can do something like this function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set('post_type', 'your-custom-post-type' ); } } } ...


0

First of all note that a post can have more than one category, also posts can have no category, what you'll do in that cases? And what about post update? That said, if you look at the url when in edit.php and select a category by clicking on its name, you'll notice that the only thing that change in the url is that the param category_name is appended to ...


0

Given that the markup of your menu does not seems to generating all of the classes I'd expect to see, I'll guess at the problem. Your theme is using a custom Walker Or something-- theme or plugin-- has added a filter to (probably) wp_nav_menu_css. Though there are other filters that could be used. To fix it, or try to, make sure your theme does not ...


0

If your problem is: I want to send email if a postmeta of a post is changed to the expected value Why do yous ask for: How can i get the List of post id on bulk edit? This is a typical x/y problem: when you have a problem, ask how to solve that problem, instead of asking ways to apply what you think is the solution... Going in the details, ...


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 ...


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

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

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", ...


0

That message is a result of your server throwing a 503 error and the WordPress Heartbeat API catching that error. See https://core.trac.wordpress.org/ticket/25660 for the background on the fix that WordPress introduced to save offline edits. Things to check on your computer are if WAMP is actually running when you're getting this message (check the status ...


0

You need to set the number of arguments your filter accepts: add_filter( 'the_title', 'alternatives_title', 10 /* Priority */, 2 /* Arguments */ ); And you only need to use the_title (there is no get_the_title filter).


1

Widget Context allows this as standard. You can select to only how on pages that more than or less than a set number of words!


0

If you want your posts based on different categories you should use category_name or cat as category id. For example; <?php $test = new WP_Query('cat=1&showposts=1'); // where 1 is the id of your cat ?> Or <?php $test = new WP_Query('category_name=errands&showposts=1'); ?> Also, you need to call wp_reset_postdata(); after each ...


0

Not sure if you are asking how to do this, but it's a setting in Settings > Permalinks. You would select the Day and Name option. This should automatically format your Post articles in this format.


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

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 ...


-4

I know this is an old post. However none of these answers are correct, and I wanted to post the solution I used to solve this problem. The best way to set a parent page through all of your posts is through the (Appearance -> Customize) menu. You can set a static page for your home page or posts page. When you set a static post page, that page will be the ...


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() { ...


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 ...


0

to add parameter to post url (permalink), i use like this: add_filter( 'post_type_link', 'append_query_string', 10, 2 ); function append_query_string( $url, $post ) { return $url.'?my_pid='.$post->ID; } output: http://yoursite.com/pagename?my_pid=12345678


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 ); ...



Top 50 recent answers are included