check if wordpress is updating or publishing a post
I avoid the problem just checking if the ID of the post is already existing in the db. get_post($id)==NULL That’s probably the easiest way to do what I need.
I avoid the problem just checking if the ID of the post is already existing in the db. get_post($id)==NULL That’s probably the easiest way to do what I need.
The markup to display each regular post item is hard coded in different template files. There is now way to get it automatically – unless the theme author has used a dedicated function for this.
First of all, welcome to WPSE! By default, the comment box does not come with the post object, what you are looking for is the comments_template function. It should be as simple as changing your code to this: <?php $post_id = 104; $queried_post = get_post($post_id); $content = $queried_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, … Read more
It might actually still work, but the syntax is currently wrong (you have a PHP opening tag inside another opening tag). And you can assign the value of the custom field to a variable using the get_field function. What if you try this? <?php // assuming your ACF name is ‘number_of_posts’ $numposts = get_field(‘number_of_posts’); $args … Read more
You could always use the has_excerpt() function to test for excerpt content and if it is not filled in you could display a message. Example: if( has_excerpt() ) { the_excerpt(); } else { echo ‘<p>Please enter the excerpt.</p>’; }
Analysing the Error WordPress database error 42000 : [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near ‘wp_users’. for query SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ”wp_users” made by display_setup_form, pdo_wpdb->query, pdo_wpdb->_post_query, pdo_wpdb->print_error …reads as: SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE ”wp_users” Your Problem It seems you got constants in your query string. And … Read more
You can solve this in different ways. One it’s to use simple querys with WP_Query and using the p parameter to retrive a particular post like it’s explained here. Something like this: $the_query = new WP_Query( ‘p=123′ ); while ( $the_query->have_posts() ) : $the_query->the_post(); the_content(); endwhile; Where 123 it’s the post id from where you … Read more
How about something along these lines? function my_filter_where( $where=”” ) { global $post; $where .= ‘ AND post_date <= “‘.$post->post_date.'”‘; return $where; } add_filter( ‘posts_where’, ‘my_filter_where’ ); $query = new WP_Query( $query_string ); remove_filter( ‘posts_where’, ‘my_filter_where’ );
get_the_content() does what it’s supposed to, gets the content. You’re looking for get_the_excerpt(). 😉 Alternatively, using what you have, it should cut off wherever you put <!– more –> in your post when using get_the_content().
With CSS: If your theme uses post_class() on a containing element, you can target that element with the class .category-songs to control styling. With a template filter: add a filter to single_template and check the assigned categories for your songs category, and use the template songs-single.php if that category is found: function wpse_check_single_categories( $template=”” ){ … Read more