WordPress.org

Forums

Split "twentytwelve_entry_meta" (5 posts)

  1. wen.wainwright
    Member
    Posted 1 year ago #

    I am by no means a programmer but I've looked this over and I understand the connections in this situation (entry_meta) and the relationship between the coding in the functions.php and the content.php for the entry_meta. I want to move the author and date to under the post title and leave the categories and tags below the post. I've already moved the leave reply to the bottom of the post and all of the entry_meta to the top of the post.

    So my actual question is: Can I take half of the entry_meta (like the author and date) and give it a new name like post_meta or post_info (or something) and rearrange it in the functions.php and the content.php? The part I'm unsure about is if in the hierarchy of wordpress files is entry_meta set in stone? Or is it possible to take part and rename it and then call it from the content.php?

    If my words are incorrect in programming language/circles I apologize! I do know there are names you should use because it impacts things elsewhere. And I do have a child theme :)

  2. wen.wainwright
    Member
    Posted 1 year ago #

    So I went ahead and tried to split up the functions so that the author and date were together and the tags and category were also together but separate from the author and date. It broke it. This, I know, could mean anything from I missed a comma to I have no idea what I'm doing. But if you have the time to look it over I would appreciate it. The mistake could also be in my content.php. I'll spare you the content.php at this point. I needed to name the half of the entry-meta I was cutting up to something most likely not used elsewhere so it's cat-dog.

    if ( ! function_exists( 'twentytwelve_cat_dog' ) ) :
    
    function twentytwelve_cat_dog() {
    $categories_list = get_the_category_list( __) ', ', 'twentytwelve' ) );
    
    $tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );
    
    //Translators: 1 is the category, 2 is tag.
    
    if ( $tag_list ) {
    	$utility_text = __( 'This entry was posted in %1$s and tagged %2$s.', 'twentytwelve' );
    	} elseif ( $categories_list ) {
    	$utility_text + __( 'This entry was tagged %2 and posted in %1$s.', 'twentytwelve' );
    
    	}

    That is the first half. The author and date are in the edited other half still called "entry-meta." Let me know if you want the other half and the content.php. Thanks!

  3. bcworkz
    Member
    Posted 1 year ago #

    Yes, there's some syntax errors there and the code is incomplete. I'm not going to itemize them because I'm going to suggest a slightly different approach that should allow you to help yourself. In general, define the constant WP_DEBUG as true in wp-config.php. This will cause errors to be listed instead of just getting a blank white screen. The error messages will give you a clue to where and what went wrong. Don't forget to set it back to false when you're done.

    I suggest you try to stick to copying and moving code rather than re-writing code as much as possible until you get a better feel for appropriate syntax. Try this for example. Copy the twentytwelve_entry_meta() function definition to your child theme's functions.php. Do not rename it, and you don't really need the if(!function_exists(//... part. Be sure the if() : endif; delimiters are removed together. Copy the function definition once again in the same file, this time renaming it.

    While it's important to prevent name conflicts, it's also important for function names to make sense. Try a name like my_theme_entry_meta(). In your child theme's copy of content.php, insert a call to my_theme_entry_meta() where you want the content to appear below the title. Leave the call to twentytwelve_entry_meta() where it is. I realize this all is probably pretty much what you have done already, just making sure we're on the same page.

    Now in each version of the entry meta functions, simply comment out or edit out the portions you do not want. Avoid editing in favor of commenting out as much as possible. Editing is where syntax errors happen. As long as you are careful to comment out complete structures, commenting out is a safer technique. You need to be careful with printf() structures in that the replacement tags ('%1$s' etc.) remain coordinated with the data that follows. Test your code frequently as you make changes, while it can get tedious, you will save time tracking down errors when you know the error can only occur in the one thing you last changed.

    With this approach, you should be able to figure out what goes wrong on your own. If you still are stuck on something, I or someone else here should be able to set you straight. Good luck.

  4. wen.wainwright
    Member
    Posted 1 year ago #

    Thanks for the advice, I don't mind helping myself, I'd rather understand it and know what I'm doing. It will probably take me a couple of days to interpret all of this. When you say to go into wp-config.php, do you mean into the parent theme? (I agree cat and dog probably aren't the best names. I thought it was a little funny for the short run, cat = "categories" and dog = dog "tags" :)

  5. bcworkz
    Member
    Posted 1 year ago #

    No wp-config.php is the file that is edited when WP is first installed that contains database information, encryption salts, etc. It is in the base installation folder.

    I'm glad you're willing to learn. It's often easier for me to just hand out an answer, but I'd rather take time to help people learn so next time they have a question it is likely more advanced, thought provoking and esoteric and more interesting to answer.

    "dog tags" :D

Topic Closed

This topic has been closed to new replies.

About this Topic