Wordpress SEO - What are you looking for?

If you're looking for answers to SEO or wordpress related questions, type in a phrase and wait for hints or click enter! The results also show links to external sources.

161 articles in the database

Display entry fields and taxonomies created by Types

[ Article content is protected by Plagiashield ]

wp-toolset

Some time ago I wrote about this like w WordPress tworzyć i modyfikować bezkodowo taksonomie, pola entries i typy postów za pomocą plugs Types. Today I will show you how to display them on our website in different places. 

I will be referring to the points made in the article below:

TYPES or taxonomies, custom fields and post types in one place

Custom fields

Custom entry fields are displayed using the get_post_meta containing parameters in the order $post_id, $key, $single. You can read more about it here: https://developer.wordpress.org/reference/functions/get_post_meta/

In our case, it will look like this:

get_post_meta($post->ID, 'wpcf-field-name', true);

In place of "field-name" we enter the generated via Types the name of the slug as generated from its title (or as modified by you) along with the prefix "wpfc-". Created at the point 3.5 in a previous article.

Display fields via shortcode

You can find information about shortcodes: What are shortcodes and how to use them on the example of WP Gallery , Creating shortcodes using the example of adding an Adsense ad anywhere 

The example will include operations on two entry fields - one text, the other address url - displaying the linked text with the data taken from the post in question. All validation is done on the plugin side - if it was run when the fields were created.

To file functions.php based on the schema, we add the code:

function shortcode_field() {
global $wp_query;
$post = $wp_query->post;
$first_field = get_post_meta($post->ID, 'wpcf-first-field', true);
$second_field = get_post_meta($post->ID, 'wpcf-second-field', true);

if ( ! empty( $first_field ) ) {
return '' . $first_field . '';
 }
}
add_shortcode( 'namashortcode', 'shortcode_field' );

2. Paste into place shortcode with the name [namashortcode].

 The above link will appear when the text field is filled in. You can delete or modify the condition based on other fields 

Taxonomies

Displaying taxonomy will be done on a linked list basis. We use the function wp_get_post_terms with parameters $post_id, $taxonomy, $args. You can read more about this feature here: https://codex.wordpress.org/Function_Reference/wp_get_post_terms

wp_get_post_terms($post->ID, $post_type, array('fields' => 'names')

In the file functions.php we add the code:

function display_taxonomy_terms($post_type, $display = false) {
    global $post;
    $term_list = wp_get_post_terms($post->ID, $post_type, array('fields' => 'names'));
 
    if($display == false) {
        echo $term_list[0];
    } elseif($display == 'return') {
        return $term_list[0];
    }
}

On the spot where we want to display a list of our custom taxonomies we type:

display_taxonomy_terms('TAXONOMY NAME');

TAXONOMY NAME - Taxonomy slug. Type in with the prefix "wpcf-"

Summary

The Types extension is definitely best a tool to codelessly create and modify new elements that will allow us to extend the functionality of our websites. Thanks to it we can easily leave the blog framework in which WP keeps us by default.

Wojciech Wladzinski

O Wojciech Wladzinski

I have been dealing with SEO industry since 2008. At co day senior SEO specialist in the company Seogroup. I create and optimize large websites as well as smaller ones. I am particularly fond of the environment WordPresswhich, despite popular belief, is not just a blogging platform.
  • Internal Links and Sematics

  • Link building
  • Sematics
  • Link building has never been easier. Hundreds of link possibilities in one click.
  • See

[ Article content is protected by Plagiashield ]

SEMRush - the best tool for SEO and PPC.

en_USEnglish
Read previous post:
wordpress-plugin8
Plugins to WP, which you do not know but you should part.8

It's time for a new part in the series of plugins you don't know (most likely) but should. Yoast Comment Hacks Plugin created by...

Close