• Resolved marky_uk

    (@marky_uk)


    Got an interesting query …

    During build/development of a site, I want all WP users to be able to use the WP-Admin “Status” box to change whether something is draft, approved, published/complete, etc – so out of 200 pages, they know what’s finished, still to work on, etc.

    However, on the website I want to show EVERY page and post, regardless of status – so as the site is being built, people can see it growing quickly.

    Then I’ll show a box on the front-end website stating the status – “THIS PAGE IS CURRENTLY IN REVIEW” etc.

    I don’t want to start hacking around each of my theme template files to change WP_Query to pick up more than is necessary (which I know would be possible but downright ugly!)

    Does anyone know how to do this? Custom Status and Edit Flow don’t allow this ….

    Thanks!

    Mark

Viewing 2 replies - 1 through 2 (of 2 total)
  • Filter posts_where. Run…

    function pwhere_filter($where) {
        var_dump($where);
    }
    add_action('posts_where','pwhere_filter');

    … and I think you will see what needs to be done. That is a very simple hack that can easily be reversed when you are ready.

    Thread Starter marky_uk

    (@marky_uk)

    Hey s_ha_dum

    Brilliant reply, thank you! That’s EXACTLY the missing piece of my jigsaw puzzle.

    An example of code in case anyone is following this and wants to see the start of my solution –

    function pwhere_filter($where) {
        global $blog_id;
        $where = str_replace("'private'", "'private' OR wp_".$blog_id."_posts.post_status = 'Draft'", $where);
        //var_dump($where);
        return $where;
      }
      add_action('posts_where','pwhere_filter');

    ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘During development of site want to show ALL posts regardless of status’ is closed to new replies.