Tag Info

New answers tagged

0

Use this- while($loop->have_posts()) : $loop->the_post(); ?> <p><img src="<?php echo get_field('attorney_photo'); ?>" /></p> <p><?php echo get_field('attorney_name'); ?></p> <p><?php echo get_field('attorney_areas_of_practice'); ?></p> <?php if( ...


0

Your best bet will be a bunch of apache rewrite rules. Place something like this above the # BEGIN WordPress line in your .htaccess file: <IfModule mod_rewrite.c> RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L] </IfModule> So, using your example of redirecting /review to /reviews: <IfModule mod_rewrite.c> ...


0

Try using get_the_excerpt instead of the_excerpt (it's not the same grammar as the_content) As a sidenote, Genesis has ready-rolled functions to do what you want that don't use the_excerpt. You can find all of the below on the Studiopress website. If you're using "Content Limit on the Content Archives section on the Genesis Settings page" then use this ...


0

broad lines of what you need to do change the .htaccess to let wordpress have priority over the directory handle wordpress url parsing You have two good options for handling the parsing hook on the init action and check if the url is of a file that exists in the directory do the file check in your theme's 404.php file before outputting any html. ...


0

Not using WordPress. With that directory in place, your web server doesn't even touch WordPress when it handles the request. I would: Move as much of your stuff as possible away from using that folder Rename the rewrite rule so that it's not just /episodes/ so that it doesn't clash You could try moving the folder and adding redirects, but at that level ...


0

No idea if this makes a difference, and don't know about the Genesis either but give it a shot function excerpt_read_more_link($output) { global $post; if ( 'speaker' == get_post_type() ) { $output .= '<p><a class="speaker-more-link" href="'. get_permalink() . '">View Speaker Profile</a></p>'; } elseif ( 'resources' == ...


1

The problem was 'exclude_from_search' => true in the register_post_type options. Given that setting 'public' => true defaults to exluding from search by default I assumed that this was the correct setting. However this is in the WordPress codex for register_post_type exclude_from_search: Note: If you want to show the posts's list that are ...


0

The $post variable inside your function does not point to anything. You are declaring global $wp_query (which you are not actually using), but not global $post.


0

Theme templates are inherently not engineered to play well with plugins. As far as I remember there is still no clean and neat solution to shipping template in a plugin and have arbitrary theme pick it up. There are some libraries, such as Gamajo Template Loader, that implement shipping templates in the plugin and allowing to override them. But as far as I ...


0

In save_post action you can access to the objet of the saved post and check the post type before tagging it: add_action( 'save_post', 'add_authors_name', 10, 2 ); function add_authors_name( $post_id, $post ) { // The post types you want be tagged to $valid_post_types array $valid_post_types = array( 'post', 'community' ); if( in_array( ...


2

I found a way to get it done but I am not very happy with this procedure. Please add your answer if you find better way. Mean while, this might be of help. add_action('admin_head-edit.php','addCustomImportButton')); I only need this on edit page, so I am using admin_head-edit.php action, but you can use admin_head or some other (not very specific ...


0

Are you trying to get WordPress to return content from multiple post types with that function call? e.g. pages and custom_post_type content? If so, you should switch to get_posts and specify the post types as an array: $pages = get_posts([ 'post_type' => ['page', 'custom-post-type'] ]);


0

There are a lot of capabilities, you can set for your post type. foreach ( self::$todo_roles as $role ) { $wp_roles->add_cap( $role, 'edit_' . self::$post_type_1 ); $wp_roles->add_cap( $role, 'read_' . self::$post_type_1 ); $wp_roles->add_cap( $role, 'delete_' . self::$post_type_1 ); $wp_roles->add_cap( $role, ...


2

You want the first parameter ($post_type) of register_post_type() – by default this is used for the "slug", so in your case it's: content-block The name and singular-name labels you refer to are just for display purposes – see get_post_type_object() for an example. So this should work (note I've not tested the rest of your advert code): if (! is_single() ...


0

Reading your comment, what you want is to create an author archive using tags and customize the author archive pages. You don't need tags or categories for that. There is a built-in author archive, by default the URL is in the format yoursite.com/author/username. That URL will show all posts by author and will use the template hierarchy as you can see here. ...


0

MY found SOLUTION WAS: global $wp_rewrite; $wp_rewrite->flush_rules(); $wp_rewrite->init();


0

Maybe you're using the wrong tool to represent relations between posts. the custom post meta fields api is somehow inefficient for that task and has certain restrictions. I advice to have a look at the "posts to posts" plugin from pipin which is much more suited for that task.


0

The link you added in your question is for Displaying the other post that share the same TERM. And I guess you want to display the all post for the current taxonomy not the single term ? Then just used the default $wp_query to do it just remove the custom wp_query and keep the loop same.


2

You need to use the AND (&&) operator to make this work. As your condition stands, it will return true no matter which page you are on. The OR operator only needs one true to execute where as the AND operator needs all conditions to be true to execute I just have one other concern here as you are loading your footer conditionally, and that is, you ...


0

You can stop executing the function if the post is not of a specific post type. You can use get_post_type() for this. if( 'masters' != get_post_type( $post_id ) ) return;


1

There's a much simplier (and more secure way*) way than hiding the user interface (show_ui=false) and adding a custom metabox to only display terms. If you remove the capability of the user to manage terms, however, not only do you have a secure solution, but user interface takes care of itself. As part of the register_taxonomy() you can specify the ...


0

This code runs "wp_insert_term" only when needed (only when querying for all terms) for better performances register_taxonomy( 'categories', null, array( 'hierarchical' => true, 'labels' => array( 'name' => 'Categories' ), 'show_admin_column' => true, 'show_ui' => true, 'query_var' => true, 'rewrite' ...


0

Alright. I figured out what I was wrong here. Because I wanted a Custom Post Type - then what I enter becomes part of that post. There's no other way around it. I could have done what I wanted to achieve by creating an Advanced Custom Field repeater and tying it to a page instead of tying it to a custom post type, but I'm not sure that would make life any ...


0

Use a WordPress Database Query but Don't Forget About Serialized Option Data The method that worked for me was to do a search and replace within the WordPress database, but making sure to not screw up serialized option data in the process. The best way I've found is to use the safe search and replace database utility from interconnect/it. Never just do a ...


2

You can just grab the first post from the main query and see which post type it is: if ( have_posts() ) { $post_type = $wp_query->posts[0]->post_type; } If you run this code directly in a main template file you should be fine, but if it's in a function you will need to call global $wp_query; first.


0

Yeah I found the answer an another website. Taxonomies have a restriction that they cannot have uppercase characters in their name they can only have lowercase and underscore characters. that`s the problem.


1

As you have already pointed out in your question, custom taxonomies are the way to go here. For this taxonomy to behave like the build in taxonomy post_tag, you need to set the hierarchical parameter to false. To make these taxonomy available to only your two specific post types, you need to specifiy this when registering your taxonomy. Example ...


1

If you are just after the term name in your code, you can add array( 'fields' => 'names' ) Or for PHP 5.4+ ['fields' => 'names'] as the third parameter to wp_get_post_terms. This will just retrieve the names of the terms attached to the post. You can then get and display the first post term name with echo $terms[0]]; As @birgire already ...


2

What about using: echo get_the_term_list( $post->ID, 'artist-genre', '<li>', ',</li><li>', '</li>' ); instead, to generate the HTML list? Or simply: the_terms( $post->ID, 'artist-genre', '<li>', ',</li><li>', '</li>' ); that's a wrapper for get_the_term_list(). Also notice that you're missing the ...


1

get_the_term_list() returns HTML but you are trying to use it as if it returned a term ID -- 'blog_cats' => $blogcats,. That is not going to work. You will need to use get_the_terms() and a tax_query (I think. I am not 100% sure). Something like: $blogcats = get_the_terms($post->ID,'category'); // var_dump($blogcats); $blogcats = ...


1

You may not need to pass in the_post(). Calling the_post() sets up the global $post object, and get_field() may also be accessing the global $post object


1

In your register_post_type call, make sure you have these arguments: register_post_type( 'my_post_type', array( 'hierarchical' => true, 'public' => true, 'rewrite' => array( 'slug' => 'my_post_type', 'with_front' => false, ), 'supports' => array( ...


0

After two days looking for the solution and fighting with the code, I found the solution: As I suspected, the problem was reading the file ($image_data = file_get_contents($image);). The first error was not included in the form enctype =" multipart / form-data " to send files and data simultaneously. The second error was that images are not loaded by ...


1

I would suggest querying a list of all post types using get_post_types. With that array you can do a foreach. and for each post type, query all terms with get_term. It would look something like this, but you should pass get_post_types your know post types, because as it stands, this will also display things like attachments and nav menus. function ...


0

Using this code snippet makes it that an author will see now only his/her own posting and is only able to edit his/her own postings. Only Admins will now be able to edit all posting. You could try to replace 'author' with 'extension_author' and see if it works for you as wished. (Add snippet in functions.php or your own plugin) function ...


0

Add the value you want before the "meaningful" url variables (city, area, etc) to the slug like this: "uk/([^/]*)/([^/]*)/?$" => 'index.php?city=$matches[1]&area=$matches[2]&something=$matches[3]', This way it will only "capture" those URL variables (city, area) if "uk" is at the beginning. A more complete example might look like this //Set ...


0

(See comments by others for your PHP error - though I'd recommend a good editor or IDE to help you spot syntax errors quickly and tidy the code for you as you type.) Re: the question title, no, you usually don't have to do a clean install if there is an error with a theme and you find yourself locked out of the main site and /wp-admin. There's a simple way ...


0

Right now you have: if ( $latest->have_posts() ) { while ($latest->have_posts()) : $latest->the_post(); ?> ... inside the loop <?php endwhile; } Which in pseudocode is: if we have posts foreach post show the post endforeach endif So you need to do this instead: if we have posts open wrapper div foreach post ...


0

If I understand you correctly, you want to modify your code so it looks like this at the top: <div class="new_wrapper"> <?php $args = array( and this at the bottom: <?php endwhile; } ?> </div> <?php $v = array(); It sounds like you may have been adding the <div></div> inside the <?php ?> code, which would have ...


0

You should open div right before argsand <?php and close it right after endwhile, if I got question right.


0

I resolved this in the end with some careful jQuery code that is run via a new JS file that is only loaded via the admin system pages. To give an example of the jQuery code... jQuery('.wrap a').each(function() { if ( getCurentFileName()=="revision.php" ){ var text = jQuery(this).text(); jQuery(this).text(text.replace('← Return to post ...


1

Thanks to Rarst for the tip. Here is the code I came up with to accomplish redirects for two similar taxonomy/post type set ups. This basically does what I indicated in the OP. If I hit a single post with a top-level term assigned to it, the url will go from domain/series/post/ to domain/series/ It simply strips the post's slug from the end of the url. ...


0

There is a template_redirect hooks which is perfectly suitable for task like this. Hook into template_redirect Check your context (is_single(), etc) Redirect with wp_safe_redirect() (if it's inside a site) die() to prevent execution from proceeding


0

By default WP_Query() will query posts (unless tax_query is set). You can change this by setting the post_type key in your $args array. To search for the same post type as is being currently viewed you can do the following: $args=array( 'post_type' => get_post_type(), //gets the post type of the current 'post' 'tag__in' => ...


1

remove_post_type_support() doesn't support arrays. You have to unregister each feature separately. See: https://codex.wordpress.org/Function_Reference/remove_post_type_support https://core.trac.wordpress.org/browser/tags/4.1.1/src/wp-includes/post.php#L1746


0

with the 4th parameter of wp_mail() you can extend the header of the Email. So you can use BCC there. This should work: <?php $bcc = 'Bcc: '; $i = 0; foreach( $emails as $email ){ if( $i != 0 ) $bcc .= ', '; $bcc .= $email; $i = 1; } $headers[] = $bcc; wp_mail( 'admin@mysite.com', 'New entry!', ...


0

There's no need as WordPress will use the default page template however you can create a custom single-cpt.php file where cpt is the name of your registered post type. <?php get_header(); ?> <div id="main-content" class="main-content"> <div id="primary" class="content-area"> <div id="content" class="site-content" ...


0

Custom Post Type in wordpress.Basic four steps.Step1: File Path location : theme/function.php in your theme.Paste code in function.php (register custom post type ) <?php add_action( 'init', 'custom_post_type_func' ); function custom_post_type_func() { //posttypename = services $labels = array( 'name' => _x( 'Services', 'services' ), ...


4

The issue, I believe, is that if ($stories) is always returning true, een if there are no posts. It's then looping through the WP-Query elements, not the actual posts. Try this instead: if ( $stories->have_posts() ) { while ( $stories->have_posts() ) : $stories->the_post(); echo get_the_title( get_the_ID() ); endwhile; ...


-1

No, this is not possible. Only pages and posts are able to work without a permalink base. When working with custom post types, you always have a permalink base. That's just how WordPress works. And the third line of your example can't work when country is already a child of region, because the parent-child relation defines the permalink structure.



Top 50 recent answers are included