Custom Post Types – How to have a dynamic slug and render the archive {post_type} .php?

So I have a custom post type named network and the name company_category for the custom taxonomy. Everything is fine until I can no longer render http: // localhost / digitalhxstaging / company. Both the company category and the company are all good, with the exception of archive-network.php. I've tried to remove the dynamic slug and how it works, but now my company category and company post are not showing the correct link. Please help me. I hope that makes sense. Below is the code with post link function.

public function company_post_type () {
$ labels = array (
& # 39; name & # 39; => _x (& # 39; company & # 39 ;, company & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & singular_name; => _x (& # 39; company & # 39 ;, & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & menu_name; => _x (& # 39; companies & # 39; companies & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & name_admin_bar; => _x (& # 39; company & # 39; company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & add_new; => __ (& # 39; Add New & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & add_new_item; => __ (& # 39; add new company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & new_item; => __ (& # 39; New Company & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & edit_item; => __ (& # 39; edit company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & view_item; => __ (& # 39; View Company & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & all_items; => __ (& # 39; all companies & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & search_items; => __ (& # 39; search companys & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & parent_item_colon; => __ (& # 39; parent: & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & not_found; => __ (& # 39; no company found. & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & not_found_in_trash; => __ (& # 39; No company found in Recycle Bin. & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & featured_image; => _x (& # 39; Company Cover Image & # 39 ;, & # 39; overrides the phrase & # 39; Featured Image & # 39; for this post type. Added in 4.3 & # 39; dhx-portal & & gt; # 39),
& # 39; # 39 & set_featured_image; => _x (& # 39; Define Title Picture & # 39 ;, & # 39; Overrides the phrase "Set Selected Picture" for this post type. Added in 4.3 & # 39; dhx-portal & # 39 ;,
& # 39; # 39 & remove_featured_image; => _x (& # 39; Remove Cover Image & # 39 ;, & # 39; Overrides the "Remove Selected Image" phrase for this post type. Added in 4.3 & # 39 ;, dhx-portal & # 39;
& # 39; # 39 & use_featured_image; => _x (& # 39; Use as title image & # 39 ;, & # 39; Overrides the phrase "Use as featured image" for this post type. Added in 4.3, & # 39; dhx-portal & # 39;
& # 39; # 39 & archives; => _x (& # 39; Company archives & # 39 ;, & # 39; The Post Type Archive label used in navigation menus, Default "Post Archives." Added in 4.4 & 39 ;, & # 39; dhx-portal & # 39 ),
& # 39; # 39 & insert_into_item; => _x (& # 39; Insert in company & # 39 ;, & # 39; Overrides the expression & # 39; Insert in post & # 39; / & # 39; Add in page & # 39; (when inserting media used in a post). Added in 4.4 & # 39 ;, dhx-portal & # 39 ;,
& # 39; # 39 & uploaded_to_this_item; => _x ("Uploaded to this company", "Overrides the Uploaded to this post" / "Uploaded to this page") (used when viewing attached media). Added in 4.4 & # 39 ;, dhx-portal & # 39; )
& # 39; # 39 & filter_items_list; => _x (& # 39; Filter companies list & # 39 ;, & # 39; screen reader text for the filter link header in the list of post types screen Default setting: Filter posts list / Filter pages list Added in 4.4 & # 39 ;, & # 39; dhx portal & # 39;),
& # 39; # 39 & items_list_navigation; => _x (& # 39; company list navigation & # 39 ;, & # 39; screen reader text for the pagination heading on the list of post types list. Default Posting List Navigation / Page Navigation default. Added in 4.4 & '; & # 39; dhx-portal & # 39;),
& # 39; # 39 & items_list; => _x (& # 39 ;, company list & # 39 ;, & # 39; screen reader text for the item list heading on the list of post types default setting "Post List" / "Page List" added in 4.4 & # 39, & # 39; # 39 & textdomain),
);

$ args = array (
& # 39; labels & # 39; => $ labels,
& # 39; # 39 & taxonomies; => array (& # 39; company_category & # 39;),
& # 39; public & # 39; => true,
& # 39; # 39 & publicly_queryable; => true,
& # 39; # 39 & show_ui; => true,
& # 39; # 39 & show_in_menu; => true,
& # 39; # 39 & menu_position; => 5,
& # 39; # 39 & menu_icon; => & # 39; dashicons-building & # 39 ;,
& # 39; rewrite & # 39; => array (& # 39; slug & # 39; => & # 39; company /% company_category% & # 39 ;, & # 39; with_front & # 39;;> false),
& # 39; # 39 & query_var; => true,
& # 39; # 39 & capacity_type; => & # 39; post & # 39 ;,
& # 39; # 39 & has_archive; => true,
& # 39; hierarchically & # 39; => true,
& # 39; supported & # 39; => array (& # 39; title & # 39 ;, & # 39; author & # 39 ;, custom fields & # 39;
);

register_post_type (& # 39; network & # 39 ;, $ args);
flush_rewrite_rules ();
}

/ **
* Company-specific taxonomy
* @since 0.1.0
* @access public
* /
public function company_taxonomy () {

$ labels = array (
& # 39; name & # 39; => __ (& # 39; enterprise categories & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & singular_name; => __ (& # 39; Category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & search_items; => __ (& # 39; search categories & # 39 ;, dhx-portal & # 39;),
& # 39; # 39 & all_items; => __ (& # 39; All categories & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & parent_item; => __ (& # 39; Parent & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & parent_item_colon; => __ (& # 39; Parent: & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & edit_item; => __ (& # 39; edit category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & update_item; => __ (& # 39; Update Category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & add_new_item; => __ (& # 39; add new category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & new_item_name; => __ (& # 39; new category & # 39 ;, & # 39; dhx-portal & # 39;),
& # 39; # 39 & menu_name; => __ (& # 39; Categories & # 39; dhx-portal & # 39;),
);

$ args = array (
& # 39; hierarchically & # 39; => true,
& # 39; labels & # 39; => $ labels,
& # 39; # 39 & show_ui; => true,
& # 39; # 39 & show_admin_column; => true,
& # 39; # 39 & query_var; => true,
& # 39; rewrite & # 39; => array (& # 39; slug & # 39; => & # 39; company & # 39 ;, with #front & # 39; => false),
);

register_taxonomy (& # 39; company_category & # 39 ;, array (& # 39; company_category & # 39;), $ args);
flush_rewrite_rules ();
}

/ **
* Company Permalink
* @since 0.1.0
* @access public
* /
public function company_post_link ($ post_link, $ id = 0) {
$ post = get_post ($ id);
if (is_object ($ post)) {
$ terms = wp_get_object_terms ($ post-> ID, & # 39; company_category & # 39;);
if ($ terms) {
return str_replace (& # 39;% company_category% & # 39 ;, $ terms[0]-> snail, $ post_link);
}
}
return $ post_link;
}

Here is the correct URL that works

enter Here is the correct URL that works

Let me know what you think. I only need http: // localhost / digitalhxstaging / company to work

custom post types – disabling post_type in URL

When you register your custom post type, tell WP if it's a CPT public_queryable,

And that argument says …:

Whether queries can be run as part of frontend
parse_request ().

Default: value of the public argument

Note: The queries
affected are the following ones (also initiated when rewrite
handled)

  • post_type = {post_type_key}
  • ? {post_type_key} = {single_post_slug}
  • ? {post_type_query_var} = {single_post_slug}

So if you do not want these posts to be queried, you should submit them not correct as this argument.

wp query – Can I dynamize the posttype value in ajax.php in WordPress?

    "Allkitchenposts"
& # 39; order & # 39; => & # 39; DESC & # 39 ;,
"post_status" => "Publish",
& # 39; # 39 & paged; => $ paged,
& # 39; # 39 & posts_per_page; => & # 39; 10 & # 39;
));

if ($ query-> have_posts ()):

while ($ query-> have_posts ()): $ query-> the_post ();

// get_template_part (# template-parts / content #, get_post_format ());
?>

          
<a href = ""> <img src = "http://wordpress.stackexchange.com/"alt =" "class =" img-responsive "/> <img src = "/img/news-thumb-01.jpg "class =" img-responsive "/>
<a href = ""class =" text-gray-base ">
  • by
<? php endtime; endif; wp_reset_postdata (); to die();

}

?>

Instead of & # 39; post_type & # 39; => & # 39; allkitchenposts & # 39; I want to make this value dynamic based on my post type, so I can load content to other archive pages with ajax, just as I described in Archive-Allkitchenposts.php

      
<a class = "btn btn -lg btn-default sunset-load-more" data-page = "1" data-url = ""> Load more ...

The following is my ajax-load.js file

jQuery (document) .ready (function ($) {


$ (document) .on (& # 39; click & # 39 ;, sunset.load-more & # 39 ;, function () {

// that refers to the button itself
var das = $ (this);
// Reference to the data page attribute value of the button
var page = $ (this) .data (& # 39; page & # 39;);
// reference to the next page
var newPage = Page + 1;
// reference to the data URL attribute value of the button
var ajaxurl = that.data (& # 39; url & # 39;);


$ .ajax ({

url: ajaxurl,
type: & # 39; post & # 39; // post method of retrieving data
Dates : {

Page: Page,
Action: & # 39; sunset_load_more & # 39;

},
Error: Function (Response) {
console.log (answer);
},
Success: Function (Response) {

that.data (& # 39; page & # 39 ;, newpage);
$ (& # 39; sunset-posts-container & # 39;). attach (answer);

}

});


});



});

I would like to know how to load more posts from Ajax for different custom page archive pages? Currently, I can only do this for one post type.
Many Thanks 🙂

wp query – How do I add a pagination in a post_type attachment?

I have a WordPress page that displays all attachments attached to a post, not the post itself. I want to add pages.

The problem is that the pagination will only be displayed if I change the "blog ads" in the read settings to "2" if I have 4 posts. It does not count the number of images attached to these posts. / page / 3 / generates a "file not found" error.

So how do I do it so that the pagination feature does not read / count the posts, but displays the total number of attachments and the correct page number, and does not produce a "File Not Found Error"?

I use FoundationPress as my starter theme

Here is my question:

    & # 39; # 39 ;, & fastening
& # 39; # 39 & post_mime_type; => & # 39; image & # 39 ;,
& # 39; # 39 & post_status; => & # 39; inherit & # 39 ;,
& # 39; # 39 & posts_per_page; => 10
);

$ query_images = new WP_Query ($ query_images_args);

$ images = array ();
foreach ($ query_images-> posts as $ image) {
$ lrgurl = wp_get_attachment_image_src ($ image-> ID, $ size = & # 39; large & # 39;);
?>
   
<img src = "http://wordpress.stackexchange.com/"/>

And that is the navigation feature of Foundation.php

// page numbering.
if (! function_exists (& # 39; foundationpress_pagination & # 39;)):
Function foundationpress_pagination () {
global $ wp_query;

$ big = 999999999; // This must be an unlikely integer

// More options and information can be found in paginate_links ().
// http://codex.wordpress.org/Function_Reference/paginate_links
$ paginate_links = paginate_links (
Array (
& # 39; base & # 39; => str_replace ($ big, & # 39;% #% & # 39 ;, html_entity_decode (get_pagenum_link ($ big))),
& # 39; current & # 39; => max (1, get_query_var (# paged #)),
& # 39; total & # 39; => $ wp_query-> max_num_pages,
& # 39; # 39 & mid_size; => 5,
& # 39; # 39 & prev_next; => true,
& # 39; # 39 & prev_text; => __ (& # 39; & # 39;, & # 39; foundationpress & # 39;),
& # 39; # 39 & next_text; => __ (& # 39; & # 39;, & # 39; foundationpress & # 39;),
& # 39; type & # 39; => & # 39; list & # 39 ;,
)
);

$ paginate_links = str_replace ("
    ","

Get a list of all custom posttype names / slugs

I'm trying to create a dropdown list of all my custom post types.

It would look like this:


I came to that get_post_types () Function that should receive a list of all registered Post items. My custom post types are not displayed …

Is it possible to get an array with the slug and the title of all post types registered in a design? Given the number, the number of post-post types is unknown and dynamic. Each time a new custom post type is added or removed, it should appear in the list.