WordPress 问题 - 自定义帖子类型

发布于 2024-11-05 20:23:43 字数 2586 浏览 1 评论 0原文

我有一个带有functions.php的自定义主题,现在我正在尝试创建一个易于更新的投资组合部分

管理部分包括

为滑块上传多个图像 显示项目中使用的技能列表 访问项目网站的按钮 简短文字 解决方案文本。

到目前为止,我的函数 php: 添加了以下内容,

<?php
$themename = "AWDTheme";
$shortname = "ts";

add_filter('the_content_more_link', 'remove_more_jump_link');

    add_action('init', 'create_portfolio');
    function create_portfolio() {
        $portfolio_args = array(
            'label' => __('Portfolio'),
            'singular_label' => __('Portfolio'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title', 'editor', 'thumbnail')
        );
        register_post_type('portfolio',$portfolio_args);
    }

    add_action("admin_init", "add_portfolio");
    add_action('save_post', 'update_website_url');
    function add_portfolio(){
        add_meta_box("portfolio_details", "Portfolio Options", "portfolio_options", "portfolio", "normal", "low");
    }
    function portfolio_options(){
        global $post;
        $custom = get_post_custom($post->ID);
        $website_url = $custom["website_url"][0];
?>
    <div id="portfolio-options">
        <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" />     
    </div><!--end portfolio-options-->   
<?php
    }
    function update_website_url(){
        global $post;
        update_post_meta($post->ID, "website_url", $_POST["website_url"]);
    }
    add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
add_action("manage_posts_custom_column",  "portfolio_columns_display");

function portfolio_edit_columns($portfolio_columns){
    $portfolio_columns = array(
        "cb" => "<input type=\"checkbox\" />",
        "title" => "Client Name",
        "description" => "Description",
    );
    return $portfolio_columns;
}

function portfolio_columns_display($portfolio_columns){
    switch ($portfolio_columns)
    {
        case "description":
            the_excerpt();
            break;              
    }
}
?>

它生成自定义帖子类型组合,并提供一个输入框来添加项目的 url。

我所坚持的是上传滑块的多个图像的方法,如果它只是使用编辑器并且不要尝试编写 WordPress 代码,那么我可以做到这一点,但希望更容易更新和添加新帖子这个类别,所以上传 3 张图像并且按滑块排序将是一个很大的帮助。

现在,技能列表是另一件事,我不确定如何实施,我希望输出为:

  • 技能 1
  • 技能 2
  • 技能 3,

就像您在其中键入技能并单击“添加到列表”的字段,然后它会变为空白以添加另一个技能,希望这是有道理的。

如果有人可以伸出援助之手,我将不胜感激,感谢所有帮助。

谢谢 乔

I have got a custom theme with a functions.php, Now I am trying to create an easy to update portfolio section

Admin section includes

upload multiple images for a slider
display a list of skills used in project
Button to visit the project website
Brief text
Solution Text.

So far added the following to my functions php:

<?php
$themename = "AWDTheme";
$shortname = "ts";

add_filter('the_content_more_link', 'remove_more_jump_link');

    add_action('init', 'create_portfolio');
    function create_portfolio() {
        $portfolio_args = array(
            'label' => __('Portfolio'),
            'singular_label' => __('Portfolio'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title', 'editor', 'thumbnail')
        );
        register_post_type('portfolio',$portfolio_args);
    }

    add_action("admin_init", "add_portfolio");
    add_action('save_post', 'update_website_url');
    function add_portfolio(){
        add_meta_box("portfolio_details", "Portfolio Options", "portfolio_options", "portfolio", "normal", "low");
    }
    function portfolio_options(){
        global $post;
        $custom = get_post_custom($post->ID);
        $website_url = $custom["website_url"][0];
?>
    <div id="portfolio-options">
        <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" />     
    </div><!--end portfolio-options-->   
<?php
    }
    function update_website_url(){
        global $post;
        update_post_meta($post->ID, "website_url", $_POST["website_url"]);
    }
    add_filter("manage_edit-portfolio_columns", "portfolio_edit_columns");
add_action("manage_posts_custom_column",  "portfolio_columns_display");

function portfolio_edit_columns($portfolio_columns){
    $portfolio_columns = array(
        "cb" => "<input type=\"checkbox\" />",
        "title" => "Client Name",
        "description" => "Description",
    );
    return $portfolio_columns;
}

function portfolio_columns_display($portfolio_columns){
    switch ($portfolio_columns)
    {
        case "description":
            the_excerpt();
            break;              
    }
}
?>

which generates the custom post type portfolio, and gives an input box to add the url of the project.

What I am stuck with is the way to upload the multiple images for the slider if its just to use the editor and don-t try and code wordpress then i can do it, but want to make it easier to updat and add new posts in this category so uploading 3 images and that was the slider sorted would be a great help.

Now the list of skills is another thing im not sure about how to implement i want the ouput to be:

  • Skill 1
  • Skill 2
  • Skill 3

so like a field where you type the skill in and click add to list then it goes blank to add another, hope that makes sense.

If someone can lend a hand i would much appreciate it, all help appreciated.

Thanks
Joe

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

听你说爱我 2024-11-12 20:23:43

我会熟悉 Pod 并走这条路: http://podscms.org/

否则,您需要在幻灯片标记内的帖子循环之外进行特殊查询,该查询利用您的自定义帖子类型,并循环遍历其所有图像附件,或者查找包含所有路径的自定义字段。

至于技能功能,我推荐WPAlchemy_MetaBox。它是一个 PHP 类,可用于快速创建 WordPress 元框。在您的实例中,您需要使用 have_fields_and_multi($name) 函数:http://www.farinspace.com/wpalchemy-metabox/#have_fields_and_multi

I would familiarize myself with pods and go that route: http://podscms.org/

Otherwise, you'll need to make a special query outside of the post loop inside your slideshow mark-up that draws upon your custom post type and either loops through all its image attachments, or looks to a custom field that has all their paths.

As for the skills functionality, I would recommend WPAlchemy_MetaBox. Its a PHP class can be used to create WordPress meta boxes quickly. In your instance, you'll need to use the have_fields_and_multi($name) function: http://www.farinspace.com/wpalchemy-metabox/#have_fields_and_multi

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文