Beginner: Where should I paste the embed codes?

I'm struggling through my first WP site and am experimenting to learn the systems. I am pretty confused about copy/pasting embed codes. My understanding is that the codes must be positioned within the "loop" section of theme templates. I am using the Portfolio Press theme. I installed the CustomPress plugin and (I think) succeeded in using it to create a custom post type with one custom field and creating a Taxonomy and populating that with content categories in two levels. I seem to have created a few custom posts which are visible on the landing page but without the custom field because (I think) I need to add embed code to the templates. CustomPress has given the required code snippets (reproduced below) but I don't know which files to place it in.

[tax id="ccss01" before="your text before: " separator=", " after=" your text after"]

<?php echo do_shortcode('[ct id="ct_Code_text_8bd8" property="title | description | value"]'); ?>

I've read a few times the CustomPress Usage document, but I'm carrying too much confusion to "get it." The document says, near the end, "First you need to find the page template you want to embed these into."
Exactly. HOW do I find the proper page template? Will I need to find several?

I'll try to put some focus on my confusion with specific questions...

[1] I noticed that the theme Responsive directory is accompanied by a same-level directory called Responsive-Child. If I use this theme I should put edited copies of the templates in Responsive-Child...right?

[2] The Portfolio Press theme does not have a similar directory. Should I make one and put the revised templates there?

[3] How can I identify the files that need embed code added? Are they always in a directory 'templates'? Should I look through each file looking for a comment about 'loop'?

[4] The Portfolio Press theme directory contains a sub-directory 'templates' which contains a few files, including portfolio.php. Here's a small section of code from that file:

<?php /* Start the Loop */ ?>
<?php while ( $portfolio->have_posts() ) : $portfolio->the_post(); ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

So...can I add the two embed snippets in the copy of the file like this?

<?php /* Start the Loop */ ?>
<?php while ( $portfolio->have_posts() ) : $portfolio->the_post(); ?>
[tax id="ccss01" before="your text before: " separator=", " after=" your text after"]
<?php echo do_shortcode('[ct id="ct_Code_text_8bd8" property="title | description | value"]'); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

[5] This revised file should go in the new directory portfolio-press-child. Or should it go in the folder portfolio-press-child/templates?

That's all I can bundle into questions for now. Any assistance will be appreciated.

David

  • Tyler Postle

    Hey David,

    Welcome to the WPMU DEV Community!

    [1] I noticed that the theme Responsive directory is accompanied by a same-level directory called Responsive-Child. If I use this theme I should put edited copies of the templates in Responsive-Child...right?

    That's correct :slight_smile: this way when your theme has an available update, it won't overwrite your edited template files.

    [2] The Portfolio Press theme does not have a similar directory. Should I make one and put the revised templates there?

    Yes, that would be a good idea :slight_smile: making a child theme is super easy, all it requires is a CSS file with a bit of information in it. Follow this guide here: http://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme

    Then once you have that setup, you can put the child theme in your Themes folder and activate it through your dashboard. Nothing will change, until you start adding templates or custom CSS to the child theme.

    [3] How can I identify the files that need embed code added? Are they always in a directory 'templates'? Should I look through each file looking for a comment about 'loop'?

    What did you name your content type? The WordPress template hierarchy is handy: http://codex.wordpress.org/Template_Hierarchy

    Basically, it's just saying what template your archives or single pages will use. If your content type doesn't have any specific template created for it then it will default to using archive.php from your theme or single.php if it's a single post.

    If you create a archive-post_type.php then your WordPress will recognize that and use that template instead. Same with single-post_type.

    http://codex.wordpress.org/Post_Types

    In this case, if your Custom post type is "movies" then you would want to create a copy of archive.php and re-name it archive-movies.php and place it in your theme directory. Add your PHP embed code into the archive-movies.php because that's what will be used to display your movie posts.

    Do the same for single-movies.php because that's the template that will be used for your single movie posts.

    [4] The Portfolio Press theme directory contains a sub-directory 'templates' which contains a few files, including portfolio.php. Here's a small section of code from that file:

    You can add the embed snippets to your portfolio template, if that's where you want the custom fields to show up :slight_smile: yes.

    [5] This revised file should go in the new directory portfolio-press-child. Or should it go in the folder portfolio-press-child/templates?

    You can put it in the root folder of the child theme. Any same named templates placed in there will be used instead of the parent theme ones :slight_smile:

    Hope this makes sense David! This sort of stuff can get pretty confusing, in-fact a lot of it still confuses me :p

    Let us know if you have any further questions!

    Have a great weekend.

    Cheers,
    Tyler

      • David

        Thanks again for your detailed reply. Making some progress here. I found where to add the embed code related to custom fields in the index.php file and the single-{name}.php file and they are working! I expect (from your comments) I'll do the same for archive.php.
        - - - - - - - - - - - - - - - - - - - - - - - - -
        I populated the custom taxonomy some more (three different levels) and linked it to a new menu and made the menu Primary (on the landing page) and it looks real nice and displays its hierarchical structure when a user drills down through the menu. I made a couple of custom posts (with functioning custom fields!!) and linked them to the appropriate sub-levels of the custom hierarchy, but the menu-to-post linkage doesn't function. When the user selects a bottom level of the menu, I expected to see the associated custom post displayed. No...bummer. I suspected the disconnect was related to the unused Taxonomy embed code.
        CustomPress indicates that an embed code (shown below) should be included in the Loop. I added it to the loop of single-{name}.php but this caused the page to go on vacation. Here's the embed code...
        <?php echo do_shortcode('[tax id="ccss01" before="your text before " separator=", " after=" your text after"]'); ?>

        [1] In which file(s) should this embed code be inserted?

        [2] Any thoughts on why the menu doesn't pass the user to the related post?

        Best...

        David

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.