how to show all post in my page-grid.php template page

<?php $args = array( ‘post_type’ => ‘put your custom PostType name here’, ‘posts_per_page’ => ‘-1’ ); $query = new WP_Query( $args ); if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); // Contents of the queried post results go here. } } // Restore original post data. wp_reset_postdata(); ?>

Hide parts of the post content on the home page

If your video is pasted into the post body, you have a couple of options. Use a filter on the_content and preg_replace to remove the content. Wrap your content in a shortcode. I am going to recommend option #2 because option #1 involves processing markup with regex which is tricky and prone to error, and … Read more

Mass Update lines of code for all posts

This script will get all posts and replace it content according to your needs: function wpse_287574_replace_content() { // Get all posts $query = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, )); $posts = $query->get_posts(); foreach ($posts as $post) { // Get content $content = $post->post_content; // Regex and replacement $regex = ‘/^(\<a\s+data-name=\”.+\”)(\>(.+)\<\/a\>)$/’; $replacement=”$1 href=”https://wordpress.stackexchange.com/items/?item=”$2″; … Read more

Odd/even class on article tag

Try this (untested): <?php $zebra = (++$j % 2 == 0) ? ‘evenpost’ : ‘oddpost’; ?> <article id=”post-<?php the_ID(); ?>” <?php post_class(‘clearfix span4 ‘ . $zebra); ?> role=”article”> You just need to place theodd/even class into a variable before passing it to post_class.

Text after more tag in posts

This will add your code after the more tag area on the post page: add_filter(‘the_content’, ‘adds_block’); function adds_block($content) { if (is_single()) { // return $content; global $post; $thePostID = $post->ID; $test=”<span id=”more-” .$thePostID.'”></span>’; return str_replace($test, ads(), $content); } } function ads(){ return ‘Your Custom Code,,’; }

Filter post before *editing*

You can use the the_editor_content filter: function wpa_editor_content( $content ) { global $post; return “this post’s id is $post->ID ” . $content; } add_filter( ‘the_editor_content’, ‘wpa_editor_content’ );

Get post embedded image caption

If I understood correctly, you are trying to add, to every image embedded in a post gallery, a custom rel attribute and a title attribute based on the attachment caption. Instead of parsing the content, you can try to modify the anchor that wraps the images using the ‘wp_get_attachment_link’ filter. <?php function wpse221533_add_caption_title_to_content_gallery_image_attachments( $markup, $id, … Read more

Comments enabled, but disabled at the same time

You can try the following function: function enable_comments() { update_option( ‘default_comment_status’, ‘open’ ); } add_action( ‘after_setup_theme’, ‘enable_comments’ ); This should enable comments for all new posts. On the other hand have you checked your theme? Some themes for some reasons have build in functions that overrides the default WP comments behavior.

Archived Posts in Wrong Category

The problem is almost assuredly your custom loop. I am guessing that this is your problem: $category = get_the_category($post->ID); $category = $category[0]->cat_ID; Further, I’m guessing that the $post object being queried here has more than one category term defined. Thus, $category[0] is returning something other than “tutorials”. Easiest solution: ensure all posts only have one … Read more

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