在我的WordPress网站上,我借助此插件添加了一个自定义小部件:https://wordpress.org/plugins/custom-post-type-widgets/
我想在PHP存档页面上显示该小部件。
我去了https://codex.wordpress.org/Function_Reference/the_widge,但没有得到我用来使小部件出现在网站上的内容。我仍然不明白如何使用它或什么名称,类等我应该在网站上使用它。
它是由主题中的选项创建的,因此无法获得如何获得它的类或ID 但是在Appearance中 - >小部件代码列在下面。
<div class="widgets-holder-wrap closed">
<div id="sidebar-18" class="widgets-sortables"> <div class="sidebar-name">
<div class="sidebar-name-arrow"><br /></div>
<h2>Custom Post Type - course <span class="spinner"></span></h2>
</div>
<div class="sidebar-description">
<p class="description">course</p>
</div>
<div id='widget-61_custom-post-type-categories-4' class='widget'> <div class="widget-top">
<div class="widget-title-action">
<button type="button" class="widget-action hide-if-no-js" aria-expanded="false">
<span class="screen-reader-text">Edit widget: Categories (Custom Post Type)</span>
<span class="toggle-indicator" aria-hidden="true"></span>
</button>
<a class="widget-control-edit hide-if-js" href="/wp-admin/widgets.php?editwidget=custom-post-type-categories-4&sidebar=sidebar-18&key=0">
<span class="edit">Edit</span>
<span class="add">Add</span>
<span class="screen-reader-text">Categories (Custom Post Type)</span>
</a>
</div>
<div class="widget-title"><h3>Categories (Custom Post Type)<span class="in-widget-title"></span></h3></div>
</div>
<div class="widget-inside">
<form method="post"> <div class="widget-content"> <p><label for="widget-custom-post-type-categories-4-title">Title:</label>
<input class="widefat" id="widget-custom-post-type-categories-4-title" name="widget-custom-post-type-categories[4][title]" type="text" value="asdf" /></p>
<p><label for="widget-custom-post-type-categories-4-taxonomy">Taxonomy:</label><select class="widefat" id="widget-custom-post-type-categories-4-taxonomy" name="widget-custom-post-type-categories[4][taxonomy]"><option value="category">Categories category</option><option value="employees_category">Employees Categories employees_category</option><option value="faq_category">Faq Categories faq_category</option><option value="news_category">News Categories news_category</option><option value="portfolio_category">Portfolio Categories portfolio_category</option><option value="testimonial_category">Testimonial Categories testimonial_category</option><option value="photo_album_category">Photo Album Categories photo_album_category</option><option value="wp_cc_tax_country">Country wp_cc_tax_country</option><option value="course-category" selected='selected'>Course Categories course-category</option><option value="expert-field">Expert fields expert-field</option><option value="internship-category">Internship Categories internship-category</option><option value="country-cost">Countries for Cost country-cost</option><option value="application-basket">Applications Baskets application-basket</option><option value="scholarship-category">Scholarship categories scholarship-category</option><option value="entry-requirement">Entry Requirements entry-requirement</option><option value="awarding-level">Awarding levels awarding-level</option><option value="intake">Intakes intake</option><option value="study-mode">Study Modes study-mode</option><option value="status">Statuses status</option><option value="course-keyword-taxonomy">Course Keywords course-keyword-taxonomy</option></select></p>
<p><input type="checkbox" class="checkbox" id="widget-custom-post-type-categories-4-dropdown" name="widget-custom-post-type-categories[4][dropdown]" />
<label for="widget-custom-post-type-categories-4-dropdown">Display as dropdown</label><br />
<input type="checkbox" class="checkbox" id="widget-custom-post-type-categories-4-count" name="widget-custom-post-type-categories[4][count]" checked='checked' />
<label for="widget-custom-post-type-categories-4-count">Show post counts</label><br />
<input type="checkbox" class="checkbox" id="widget-custom-post-type-categories-4-hierarchical" name="widget-custom-post-type-categories[4][hierarchical]" checked='checked' />
<label for="widget-custom-post-type-categories-4-hierarchical">Show hierarchy</label></p>
</div> <input type="hidden" name="widget-id" class="widget-id" value="custom-post-type-categories-4" />
<input type="hidden" name="id_base" class="id_base" value="custom-post-type-categories" />
<input type="hidden" name="widget-width" class="widget-width" value="250" />
<input type="hidden" name="widget-height" class="widget-height" value="200" />
<input type="hidden" name="widget_number" class="widget_number" value="4" />
<input type="hidden" name="multi_number" class="multi_number" value="" />
<input type="hidden" name="add_new" class="add_new" value="" />
<div class="widget-control-actions">
<div class="alignleft">
<button type="button" class="button-link button-link-delete widget-control-remove">Delete</button> |
<button type="button" class="button-link widget-control-close">Close</button>
</div>
<div class="alignright">
<input type="submit" name="savewidget" id="widget-custom-post-type-categories-4-savewidget" class="button button-primary widget-control-save right" value="Save" /> <span class="spinner"></span>
</div>
<br class="clear" />
</div>
</form> </div>