Tag Info

New answers tagged

0

I usually do this by getting data from database $result = mysql_query("SELECT * FROM wp_terms JOIN wp_term_taxonomy ON wp_term_taxonomy.term_id = wp_terms.term_id WHERE wp_term_taxonomy.parent = ".$parent_cat_ID." AND wp_term_taxonomy.taxonomy = 'product_cat'");


0

In this case you need to use Page Template. Add these line to the top of the file: <?php /** *Template Name: Post Archive */ ?> Then you will create a new page, choose Post Archive for its page template box. That is, when you visit this page, you will get your posts archive.


3

You don't, archive-post.php doesn't exist, it's just archive.php, and on most sites the post archive is the root of the site, aka /. Depending on how you're viewing posts it'll use home.php, front-page.php, index.php, etc. You should refer to the template hierarchy diagram, but remember, the standard post post type is a special case, as are pages Perhaps ...


1

I don't suspect that your tax_query is failing you, but actually your tag parameter is. single_tag_title() returns the name of the tag, not the slug. All tag and category queries are converted to a tax_query in the WP_Query class before being passed to the WP_Tax_Query class to build the relative string for the SQL query. Term names and slugs gets ...


0

Look at this section (excerpt): Day and name - An example of the day and name based structure is http://www.sample.com/2008/03/31/sample-post/ Month and name - An example of the month and name based structure is http://www.sample.com/2008/03/sample-post/ Numeric - An example of the numeric structure is http://www.sample.com/archives/123 ...


2

Do you really need to know the ID, for that see @PieterGoosens's answer, or do you just need to know if you are at the post type product archive? The latter can easily be achieved by using is_post_type_archive(): if ( is_post_type_archive( 'product' ) ) { // code }


2

If this is a true page, then you can get the ID of that specific page with get_queried_object_id(). This works and will return the ID on the specific pages, single, category, taxonomy, tag and author pages where it is used. True date and time archives and the homepage will not have ID's You can do the following $page_id = get_queried_object_id(); echo ...


1

You're right. It isn't a good structure. You are running three queries on the page-- the two you are creating plus the main query that is being completely ignored (plus ancillary queries). You are also clobbering the main query halfway through the page load when you overwrite $wp_query, which can cause unexpected and unpredictable results and difficulty ...


2

You can change it via the category template (if you have multiple category templates you'll need to edit all of them; if you have archive.php, you need to edit it only there). Otherwise you can use the Yoast SEO plugin which have settings for naming the archives (actually I think that almost all SEO plugins have those settings).


0

Ok, an answer to all. First, thank you for you help. Anyway, none of your solutions really address my issue. I don't like custom links on nav menus, at all. And that's because they're not dynamic, you cannot build them dynamically. So when you move the site and change url (for example, from staging to production) you'll have to remember to manually change ...


0

Just create an archive-{post_type}.php when you create a custom post type and include this function: flush_rewrite_rules(); Make a page of your custom post type. It's called an archive page.


2

Custom post type archive page does not need "dumb" Page. In fact, there could be the culprit. You should try this: Remove /* Template Name: Staff */ from archive-staff_member.php (not needed) Remove "dumb" stuff Page (if created). There could be some permalink conflict. Go to Admin > Settings > Permalinks and re-save it (it will regenerate rewrite rules) ...


0

Yes, the function is_post_type_archive only works in archive.php To have an item on nav menu links to your staff_member, you will add a custom link menu item in stead of a page whose template is your file tempate. The URL of that item will be got when you vardump this: get_post_type_archive_link('staff_member') And to custom the performance of the ...


1

Permalinks or the pretty url of your posts be set under permalink in settings. there you can use %hour% or many other available tags in your url


2

There was a new function introduced in Wordpress 4.1 called the_archive_title() which does just that. You can simply add the_archive_title() in your archive page. If you need to filter the output, see my answer here on how to accomplish that


0

There's an easier way, don't bother with the page at all. Instead, store the content inside an option or theme mod, and use the settings API/customiser to edit the content. To turn the textarea holding the content in your form into a full editor, use the wp_editor function to get a wysiwyg editor that looks and works like the edit page screen. Use ...



Top 50 recent answers are included