I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish

I’m afraid I don’t understand the question perfectly, so I apologize, but, $post_status=”publish”; Wouldn’t that do it? I am missing context though, are you building a query? Because to get all the posts by the current user, something like this would be needed: $args = array( “post_status” => “publish”, “author” => get_current_user_id(), “posts_per_page” => 10 … Read more

If post has non-shortcode string

That’s indeed a basic PHP question. Use strpos(). Example: if ( false !== strpos( $post->post_content, ‘foo’ ) ) { wp_enqueue_script(); } Ps. I suggest you to not hook into wp_enqueue_scripts() but a later hooks, e.g. the_content and then load the JavaScript in the footer. This works best under all circumstances as wp_enqueue_scripts and wp_head are … Read more

Wrap div-tag around posts in page

What happen if you proceed with the following syntax? <div id=”container”> <?php if( have_posts() ) : while( have_posts() ) : the_post(); ?> <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> <h2 class=”entry-title”><?php the_title(); ?></h2> <div class=”entry-content”> <?php the_content(); ?> </div> </article > <!– /#post-<?php the_post_ID(); ?> –> <?php endwhile; endif; ?> </div> <!– /#container –> The … Read more

Wrap every 2 posts

You need to start Row class after every 2N+1 post. And end the Row class after every 2N+2 Post. Try this one <?php $counter++; if ($counter % 2 == 1) : ?> <?php echo ‘<div class=”post-wrapper”>’; ?> <?php endif; ?> <?php get_template_part( ‘templates/blog/blog-2-cols’, get_post_format() );?> <?php $counter++; if ($counter % 2 == 0) : ?> … Read more

Bug with post titles [closed]

This is usually due to using custom query/loop stuff after the main query and not calling either wp_reset_postdata() or wp_reset_query() after you’re done. See this answer for more detail on which to use.

WordPress “Posts Page” isn’t showing template dropdown

Ben, Welcome to StackExchange! Page Templates are only able to be defined in the Page post type (“Pages” in the WP-admin). https://developer.wordpress.org/themes/template-files-section/page-template-files/#uses-for-page-templates You can edit your theme (or create a child theme) to define how your post pages are displayed. Depending on your needs you could define an archive.php, category.php or index.php in your theme … Read more

How to hide home title on pages and posts?

If I follow what you’re explaining correctly, try adding a document title filter to the functions.php theme file. (NB: setting to only change post and pages. Search, Archive, etc, will keep original title. You can always modify accordingly.) *** EDIT: added a filter for older themes that uses wp_title. add_filter(‘wp_title’, set_custom_page_title, 99999); //NB:backward compatibility with … Read more