Tag Info

New answers tagged

0

Looking at the function update_woocommerce_term_meta(), you would recognize it just uses the wordpress function update_metadata(), which essentially means that woocommerce is using meta values, just like you do in you CPT. With this in mind, I wouldn't think this procedure would slow down your site + your keeping compatibility by using existing functions. ...


0

Hope you did pretty url on your site already (Settings>Permalinks). If so, Let's guess your Category base is blank there. You have to add Custom posts in category archive using a filter. To do so, add this to function.php: function go_add_custom_types( $query ) { if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ...


1

you can do this to modify the definition $args = get_post_type_object("glossary"); $args->rewrite = array("with_front" => FALSE); register_post_type($args->name, $args); this has to be done after the call of "register_post_types()" of the plugin


1

My opinion, if you are the one registering and enqueing the scripts and styles, enqueue them conditionally. I don't see any use enqueueing a scripts or styles just to dequeue them later on. If you want to take the dequeue route, you need to dequeue the script or style, not deregister it Make sure your priority is correct, ie, you must dequeue the script ...


0

Your basic query logic looks fine assuming you want an AND relationship between the first, middle, and last names but query_posts is never, ever, ever the right way to do anything. Note: This function isn't meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is ...


0

Okay, it seemed that going with more than 1 taxonomy was just wishful thinking. I settled with this: CPT still is 'magazine' Hierarchical taxonomy terms were used instead: Parent: The author name Children: The magazines that each author will publish. With the code below I managed to get a working taxonomy-authorname.php page: <?php $taxonomies = ...


2

You can follow similar approach with get_the_terms. Here is the function. function add_taxonomy_to_single( $classes ) { if ( is_single() ) { global $post; $my_terms = get_the_terms( $post->ID, 'custom-taxonomy' ); if ( $my_terms && ! is_wp_error( $my_terms ) ) { foreach ($my_terms as $term) { ...


0

I just ran into this issue recently. If you are using a Custom List Table (A/K/A WP List Table) within a Meta Box (located on the post edit screen post.php or post-new.php.) The reason you get redirected to the posts listing screen (edit.php) is because you're Custom List Table generates a hidden nonce field, which is also generated by the post.php or ...


0

This question has different answers in this specific Wordpress question, they may be of help: Display all posts in a custom post type, grouped by a custom taxonomy Personally I used this method that worked for me just fine: $terms = get_terms('tax_name'); $posts = array(); foreach ( $terms as $term ) { $posts[$term->name] = get_posts(array( ...


0

Try like this $args = array( 'post_type' => 'movie', 'tax_query' => array( array( 'taxonomy' => 'producer', 'field' => 'slug', 'terms' => 'WarnerBros', ), ), ); $query = new WP_Query( $args ); See more at wordpress codex


1

Your code has a couple of flaws which I'm not going to go into detail now. Here is a short list pre_get_posts is an action On any type of archive page you need to make sure you only target the main query and the front end when using pre_get_posts Your syntax is very hard to debug and not supported by most code editors. Although if (): else : endif; is ...


0

with your code you completely redefine your CPT instead of just modifying the slug maybe this change the public access try this : $args = get_post_type_object("portfolio"); $args->rewrite["slug"] = "homepage"; register_post_type($args->name, $args);


1

To add a meta box you have to use add_meta_box function which allows us to add meta boxes to the administrative interface.But just adding a meta box doesn't make it work. You must also have a callback function that prints out the HTML for the edit screen section. In your case we need that callback function to display an area where user has control of ...


0

Best method may be JAVASCRIPT: <script type="text/javascript"> var field_id = "My_field_div__ID"; // <----------------- CHANGE THIS var SubmitButton = document.getElementById("save-post") || false; var PublishButton = document.getElementById("publish") || false; if (SubmitButton) {SubmitButton.addEventListener("click", SubmCLICKED, ...


0

You can try the following code to check whether a category with a name exist of not $search_category_name="T-shirts"; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms('product_cat', array('orderby' => 'slug', 'hide_empty' => false)); foreach ($parent_terms as $pterm) { //check whether ...


0

Try this <?php get_header(); ?> <div id="content" class="clearfix row"> <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article"> <section id="work" class="row"> <div class="span3"> <h3>Recent Work</h3> <p>Intro Lorem ...


0

You shouldn't use query_posts functions. You should create instance of WP_Query class In your theme folder create a new file called category-slug.php. You can copy the category.php file or archive.php file to create category-slug.php file. Then in the new category-slug.php file before the while loop you can write your query. $query = new WP_Query( ...


1

Here is a code snippet that will do what you described: add_action( 'pre_get_posts', 'wpsx_185734_acf_search_relationship' ); function wpsx_185734_acf_search_relationship( $q ) { $screen = get_current_screen(); $s = $q->get('s'); $post_type = $q->get('post_type'); // Be very selective when running code at the pre_get_posts hook ...


0

If the above code is looping through in a while loop is should be outputting the tabs correctly, but not the content. You need to repeat this loop again within the tab-content area. Also you need make sure that every table content area does not have class of active. The active class should only be on the first one. You can use a counter within your loop and ...


0

I will answer to my best ability point by point. Yes, wp multisite would be ideal for this and it will all be in one database. Not easy to do without a plugin, but yes there are plugins available for translations. However issues might arise, especially with regards to the customer's expectations. a) This can be a problem, as the translation plugins ...


0

You will need to learn the very basics of how Wordpress works and how templates interact to display content. Your question is rather broad looking at your actual problem. In short, a basic template should look like this <php get_header(); if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'content' ); } ...


0

I have found what is the problem. It isn't enough to localize just the labels e.g. ('Label','text_domain'). But also the variable itself - my code should be like this: add_meta_box($this->_meta_box['id'], ($this->_meta_box['title'],'text_domain'), array(&$this, $this->_meta_box['function_callback']), $page, ...


-1

Set 'posts_per_page' to 1 on your args variable. I also suggest that you add 'page-attributes' while registering the magazine's post type and order the result by 'menu_order'. This way, you will have the field Order while editing a magazine, and set the highest which should appear on this query.


0

yeah as answered by @s_ha_dum wordpress doesn't support the nested post type you can achieve it by xreating the custom taxonomy and by using parent child relation you can acheive your scenario. I am explaning the code as below. It might be helpful to you. add_action( 'init', 'create_post_type' ); function create_post_type() { ...


0

@ hannit cohen, This is best way to hide the Add New or Create New button in custom postypes 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => false ), 'map_meta_cap' => true, It disable to create new post in custom post types both side in admin menu and above the list of post ...


1

Please find the code its working you need to just add the js and css for your design it will add three custom post and add widget to the widget area you can drag and drop it in any side bar. <?php /** * Plugin Name: Custom Tabbed Plugin * Description: This is testing of the custom tabbed plugin * Version: 1.0.2 * Author: ...


1

For example if there are 10 custom posts, and No. 1 is the oldest, and they happened to select the 3rd oldest one, they want it to say "No. 3". There is a more elegant way than that function: $args = array( 'post_type' => 'book', 'fields' => 'ids', 'ignore_sticky_posts' => true, 'orderby' => 'post_date', 'order' => 'DESC' ...


0

Doh... While writing up this question it suddenly became clear why it was not working: I was hooking my buttons inside the loop and since my loop was not a single page item, get_the_id() would be getting the ID of each post in the loop, not the page that the posts were on. All I had to do was hook after the loop: add_action( 'genesis_after_loop', ...


0

I ended up going with this type of solution. It seems to be working fine for me. I am open on ways to improve this code as it seems there is a better hook that could be used. function on_music_publish( $post_ID, $post ) { if ( $post->post_type != 'music' ) { return; } update_post_meta($post_ID, '_disable_fbc', 'on' ); } ...


3

WordPress doesn't support nested post types, though you can created hierarchical types similar to the Core "Page" type. However, what you are describing, including this sample "POST+CATEGORY+SUBCATEOGRY" is a custom taxonomy for your Car post type. The Codex has examples, but you would need something like this (roughly, I am sure this needs tweaked): ...


0

You're correct in your approach. If you post your code will be better, but something like this: $args = array( 'post_type' => 'project', 'tax_query' => array( array( 'taxonomy' => 'region', 'field' => 'slug', 'terms' => $region, //set your region ), ), ); $the_query = new ...


2

pre_get_posts does not work on page templates and static front pages. It will 404. If I read the WP_Query class correctly, the page ID is passed to a parameter such as p once the URL is parsed. You can try unsetting this parameter and check if it changes the query, but I doubt if this will be the only parameter to change to make it work. Have never played ...


0

This is the working code. You can try with yours $id = get_the_ID(false); $categories = get_the_category(); $parents = array(); $childs = array(); foreach($categories as $cat){ if($cat->parent == 0){ $parents[] = $cat; ...


1

Ok, so I didn't get a reply, but I worked this out as as solution and I hope it will be useful to others. I am using the evolve template, so when you see evolve it is referring to something in the evolve template; e.g. evolve_breadcrumb() is a function used by the evolve template. This is the scenario: Custom post type: boat Types of boat: motor, sail ...


0

None of the following suggestions worked for me. Sagive SEO's function almost worked for me. I checked my database to find that the only values for comment_status are open and closed. That function inserted 1 as a value. I revised the function and it seems to work perfect now. I hope this helps someone. function default_comments_on( $data ) { if( ...


0

If your dates are saved in the following format, Y-m-d, it is quite easy. Your year will stay the same, so your can then technically sort by month. All you need is to add the correct values to the order and orderby parameters. You can try the following // Query Post Type $args = array( 'post_type' => 'events', 'post_status' => 'publish', ...


0

As ever, when you know the answer it's maddeningly simple. The custom post types were there all along, together with their taxonomy. All posts are absent from the menu editor and have to be turned on in Screen Options. I pressed the button and lo, there they were.


1

This type of ordering is not available by default. You however have two basic options here rewind_posts() -> Rerun the loop multiple times and use rewind_posts() to rewind the loop so you can rerun it again EXAMPLE if ( have_posts() ) { while( have_posts() ) { the_post(); if ( $post->post_type == 'books' ) { // Output ...


1

as ChrisL said in the comments, you should add order and orderby to your arguments : $args = array( 'post_type' => 'totem', 'posts_per_page' => -1, 'orderby' => 'title', 'order' => 'ASC' );


0

Please try with the wordpress in build function get_page_hierarchy( $posts, $parent ) Reference URL : https://codex.wordpress.org/Function_Reference/get_page_hierarchy


0

here is the mysql query you can use to get the result having distance less then your value. SELECT * , pm1.meta_value as latitude, pm2.meta_value as longitude , (((acos(sin(([latitude]*pi()/180)) * sin((pm1.meta_value * pi()/180)) + cos(([latitude]*pi()/180)) * cos((pm1.meta_value * pi()/180)) * cos((([longitude] - ...


2

I didn't know that I can register a taxonomy for more than 1 CPT/post type! register_taxonomy( 'location', array( 'offer', 'store' ), array( 'label' => __( 'Location', 'themeify' ), 'hierarchical' => true, 'labels' => array( 'name' => __( 'Location', 'themeify' ), ...


0

It seems that you could use Types and Views plugins (with Views "Parametric search" feature). Views is commercial, but unless you are building your personal website, I think it's worth it. Nice writeup about those plugins is, for example, here: http://www.neilcurtis.me/guides/best-wordpress-plugins/


0

It doesn't look like you're passing your search query in your WP_Query args. To do this on a custom search page try the following: Replace this: $the_query = new WP_Query('post_type=darpe-entries'); With this: global $query_string; $query_args = explode("&", $query_string); $search_query = array(); foreach($query_args as $key => $string) { ...


0

It seems to me like this is just a regular addition to functions. Since you are asking, I think you may not be getting the result you are looking for. If this was my project, I would create a new plugin, install it into the regular plugin list so that it does not get overwritten anywhere and then add the new properties. Create a file called ...


0

It seems that at that point, $post is not yet defined, you can make sure by turning debugging on. Then add this before your get_post_meta( $post...: global $post; Or you can replace $post->ID with get_the_ID().


0

I'm don't know a way of re-using the page picker but you could achieve what you're trying to do with the "Post Object" field type in the Advanced Custom Fields plugin. The post object field creates a select field where the choices are your pages + posts + custom post types. This field is useful for advanced linking to another page / post. ...


0

The theme is using custom post type and you are right to worry about using it. If you start using this theme, you are doomed in the sense that you can't change it later without breaking the site. My personal opinion on theme is that it should only work on the visual aspect and leave the functionality part to the plugin. But so many themes break this rule ...


2

Here's a simple plugin to modify the Press-This post type: <?php /** * Plugin Name: Custom Press-This Post Type * Plugin URI: http://wordpress.stackexchange.com/a/192065/26350 */ add_action( 'wp_ajax_press-this-save-post', function() { add_filter( 'wp_insert_post_data', function( $data ) { if( isset( $data['post_type'] ) ...


0

The theme is using a custom post type, in this case, "lyrics". Converting the old posts over to it should be as simple as writing a single query to update the old posts to the new post type. The query will be something like: UPDATE `wp_posts` SET post_type = "lyrics" WHERE post_type = "post"; Just as an added precaution, run this one first to ensure that ...



Top 50 recent answers are included