简体   繁体   中英

I see my URL but I can't find the page in wordpress dashboard

I'm using wordpress and my page has the URL http://proservicescontractors.com/services/

But when I go to the page in my dashboard with the above URL, any change I make does not show on the front end. I tried simply duplicating my content and that change did not show on the front end.

Not sure what to do, this has me completely baffled.

Any ideas?

Since they're custom post types, by default, they're not actually loaded into a page per se. You should read up on WordPress's template hierarchy. To give you a rough idea of what's happening:

  1. WP looks at your URL, and since it recognises it as a custom post type archive, it will look for a template to use...
  2. It will first look for archive-$post_type.php , or in your case, archive-services.php
  3. If it can't find that, it will look for archive.php
  4. If it can't find that, it will use index.php

The important thing to note is that archive pages don't actually show up in the admin area, since they simply gather up and display custom posts, so there's nothing for you to edit.

Now, if you really want to edit some content on the Services archive, you have two options:

Edit archive-services.php in a text editor.

This is the quick and dirty option; the downside is that it defies the point of a CMS.

Create a page template with it's own loop

Create a new page template called page-services.php and insert a loop in there to display your custom posts. To get you started:

<?php get_header(); ?>

<?php // The main loop  
if (have_posts()) {
    while (have_posts()) {
        the_post();
    }
} else {
    echo 'No posts';
}
?>

<?php // Now for the services loop
// WP_Query arguments
// For additional options, see: https://codex.wordpress.org/Class_Reference/WP_Query#Parameters
$args = array (
    'post_type' => array( 'services' ),
);

// The Query itself
$query = new WP_Query( $args );

// The Loop
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        // Do something with the post
        // In your case look at archive-services.php and see what
        // that template does inside the loop
    }
} else {
    // no posts found
}

// Restore original Post Data
// Don't forget this, it's important
wp_reset_postdata();
?>

<?php get_footer();?>

You should then be able to apply that page template to your Services page; it should then display your posts below the page content. One thing to look out for is that WordPress will continue to load archive-services.php whenever you go to http://proservicescontractors.com/services/ . While there are ways around this, the easiest fix would be to simply give your new page a different url, such as http://proservicescontractors.com/all-services/

Thanks for your help. I'm using yoast and I wanted to change the title and description. When you pointed out that it was a custom post type archive and not a page, I went back through yoast and found where I could change them under "Titles and Metas" > "Custom Post Type Archives" > "Services"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM