如何在WordPress中正确导航(使用自定义帖子)? [英] How do I navigate proprely in WordPress (using custom posts)?

查看:151
本文介绍了如何在WordPress中正确导航(使用自定义帖子)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用WordPress和Bootstrap重新设计我的网站。我完成了大部分工作,但是,我无法浏览我的页面。



在我告诉你任何事情之前,只是想让你知道我的教程是tutorijali和我的教程是tutorijal。所以只是在那里添加j(因为我不是来自英格兰或英语国家)。



好​​的,所以,我做了一个自定义的帖子类型 tutorijal。但是,我注意到当自定义帖子类型的名称是tutorijal时,我得到这样的URL:



domain-name / tutorijal /



由于tutorijal是单数并且tutorijali是复数,我将自定义帖子类型的名称更改为tutorijali(这样我的URL就像我一样希望它去)。



然后我制作了page-tutorijali.php并将该主题(我将其命名为Tutorijali theme)应用到我的XHTML和CSS页面。但是,发生的事情是我有冲突。



在WordPress中,我有一个名为Tutorijali的Wordpress页面,我的自定义帖子类型名称也是tutorijali 。



你可以在这里看到我的导航结构并注意到我有一个WordPress页面,其名称与我的自定义帖子类型相同,Tutorijali: http://imgur.com/2zgH5dD



如果我去



domain-name / tutorijali / xhtml-and-css



我得到我的默认发布模板,而不是我申请的Tutorijali主题。然而,Tutorijali主题应用于Tutorijali WordPress页面,没有我设置它应用。



所以,如果你去



domain-name.com/tutorijali




你可以看到所有的有序列表但是,如果您转到WordPress页面Tutorijali的特定子项目,即使您专门将WordPress页面(从管理面板)更改为Tutorijali模板,也会获得默认的帖子模板。 br $> b $ b

也许我的WordPress页面和我的自定义帖子类型不能共用同一个名字,我不确定。



现在,我在用户去的时候



domain-name / tutorijali



我希望他只有教程系列的名字,但如果他继续使用一个特定的系列,那就说XHTML和CSS,那么URL将是


domain-name / tutorijali / xhtml-and-css



和th用户可以在有序列表中获得所有XHTML和CSS教程。



我有一个父自定义帖子,名为XHTML和CSS(作为我的教程系列)名称)和它的子元素(也是名为tutorijali的自定义帖子)是来自该系列的特定教程。



我还有另外一个问题,那就是我的list也显示父帖子,所以我的列表如下:



XHTML和CSS(因为它的order值设置为0)

安装程序(订单设置为1,依此类推)

标签

网站的基本元素......



所以我想摆脱它并获得我想要的结构(在Tutorijali上 - 教程系列名称,特定教程系列 - 教程列表)。



这是我的页面代码-tutorijali.php:





I want to redesign my website using WordPress and Bootstrap. I did most of the work, however, I have trouble navigating through my pages.

Before I tell you anything, just want you to know that my "tutorials" is "tutorijali" and my "tutorial" is "tutorijal". So just added that "j" there (because I'm not from England or English-speaking country).

OK, so, I made a custom post type "tutorijal". But, I noticed that when the custom post type's name is "tutorijal", I get the URL like this :

domain-name/tutorijal/

Since "tutorijal" is singular and "tutorijali" is plural, I changed the custom post type's name to "tutorijali" (so that my URL goes as I want it to go).

Then I made page-tutorijali.php and applied that theme (which I named "Tutorijali theme") to my XHTML and CSS page. But, what happens is that I have a conflict.

In WordPress, I have a Wordpress page named "Tutorijali" and my custom post type's name is also "tutorijali".

You can see my navigation structure here and notice that I have a WordPress page which is named the same as my custom post type, "Tutorijali" : http://imgur.com/2zgH5dD

If I go to

domain-name/tutorijali/xhtml-and-css

I get my default post template and not the "Tutorijali theme" I applied. However, that "Tutorijali theme" is applied on Tutorijali WordPress page, without me ever setting it to be applied.

So, if you go to

domain-name.com/tutorijali


you can see the ordered list with all of the tutorials, however, if you go to a specific sub-item of the WordPress page "Tutorijali", you get the default post template, even if you specifically change that WordPress page (from the Admin panel) to "Tutorijali template".

Maybe my WordPress page and my custom post type can't share same name, I'm not sure.

Now, I when the user goes to

domain-name/tutorijali

I'd like him to have only the names of tutorial series, but if he goes on one specific serie, let's say XHTML and CSS, then the URL would be

domain-name/tutorijali/xhtml-and-css

and the user would get all of the XHTML and CSS tutorials in ordered list.

I have a parent custom post which is named "XHTML and CSS" (as my tutorial serie name) and it's child elements (also custom posts named "tutorijali") are specific tutorials from that serie.

I also have one other problem, and that is that my list is also displaying the parent post, so my list goes like this :

XHTML and CSS (since it's "order" value is set to 0)
Installing the program ("order" set to 1 and so on)
Tags
Basic elements of a website ...

So I'd like to get rid of that and obtain the structure I wanted (on Tutorijali - tutorial serie names, on specific tutorial serie - list of the tutorials).

Here's the code for my page-tutorijali.php :


<?php
/*
        Template Name: Tutorijali Template
*/
?>
<?php get_header(); ?>
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                  <div class="page-header">
                        <h1><?php the_title(); ?></h1>
                  </div>
                  <?php the_content(); ?>
                  <?php endwhile; else :?>
                  <div class="page-header">
                        <h1>O ne!</h1>
                  </div>
                  <p>Na ovoj stranici nema sadržaja.</p>
                  <?php endif; ?>
        </div>
      </div>
        <div class="row">
                <div class="col-md-12">
    <?php
            $args = array( 'post_type' => 'tutorijali', 'order' => 'asc', 'posts_per_page' => -1 );
            $the_query = new WP_Query( $args );
            echo "<ol>";
            if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
                    echo "<li>";
                                        echo "<a href='".get_permalink()."'>".get_the_title()."</a>";
                                        echo "</li>";
            endwhile; endif;
            echo "</ol>";
    ?>
                </div>
        </div>
<?php get_footer(); ?>







我也有一个关于我的single-tutorijali.php的问题。我创建它以显示这些自定义帖子页面不同于普通帖子。我很好地链接到上一个和下一个教程,但是,我不知道如何从教程链接到列表。



所以让我们说用户在教程安装程序,URL将会:



domain-name / tutorijali / xhtml-and-css / installed-the-程序



如果他点击链接将他带回名单,他会去:



domain-name / tutorijali / xhtml-and-css



但是我很难做到这一点,所以也许你可以告诉我怎么做。



这是我的单一tutorijali.php的代码:








I also have a question regarding my single-tutorijali.php. I have created it to display these custom post pages differently than "normal" posts. I link to the previous and to the next tutorial well, however, I don't know how I can link from a tutorial to the list.

So let's say the user is at the tutorial "Installing the program", URL would go :

domain-name/tutorijali/xhtml-and-css/installing-the-program

and if he clicks on the link to take him back to the list, he would go to :

domain-name/tutorijali/xhtml-and-css

but I have trouble doing that, so maybe you can tell me how I can do that.

Here's the code for my single-tutorijali.php :


<?php get_header(); ?>
    <div class="container">
      <div class="row">
        <div class="col-md-12">
          <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                  <div class="page-header">
                        <h1><?php the_title(); ?></h1>
                  </div>
                  <?php the_content(); ?>
                  <?php endwhile; else :?>
                  <div class="page-header">
                        <h1>O ne!</h1>
                  </div>
                  <p>Na ovoj stranici nema sadržaja.</p>
                  <?php endif; ?>
        </div>
      </div>
          <div class="row">
                <div class="col-md-12 yt-link">
                        <p> <a class="btn brn-large btn-primary" href="<?php the_field('link'); ?>"> Pogledajte tutorijal na Youtube -u </a> </p>
                </div>
          </div>
          <div class="row">
                <div class="col-xs-12 prev-next">
                        <?php previous_post_link('%link', '<span class="glyphicon glyphicon-circle-arrow-left"></span>'); ?>

                        /-- this is that link I was talking about, one that takes you back to the list of tutorials
                        <a href=""><span class="glyphicon glyphicon-th-list"></span></a>
                        /--

                        <?php next_post_link('%link', '<span class="glyphicon glyphicon-circle-arrow-right"></span>'); ?>
                </div>
          </div>
<?php get_footer(); ?>





感谢您的阅读!



Thank you for reading!

推荐答案

args = array(' post_type ' => ' tutorijali' ' order' => ' asc '' posts_per_page' => -1);
args = array( 'post_type' => 'tutorijali', 'order' => 'asc', 'posts_per_page' => -1 );


the_query = new WP_Query(
the_query = new WP_Query(


args );
echo < ol>< /跨度>;
if (have_posts()): while
args ); echo "<ol>"; if ( have_posts() ) : while (


这篇关于如何在WordPress中正确导航(使用自定义帖子)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆