Wordpress Help

by 9 replies
11
Is there anyway to edit the HTML of a single post on Wordpress?

Let's say that I have an image in my single.php that shows up on all of the posts on my site. However, I don't want that image on one of those posts. How can I remove that image from the single post that I don't want it on?
#programming #wordpress
  • Hi Mike,

    When you say page.php are your referring to theme file for pages?

    If that is the case.. then simple copy that page.php to some page1.php theme
    file in your theme folder. And simply remove that image line from it.
    It is called Page Templates...

    Pages « WordPress Codex

    Pages « WordPress Codex

    Then for the post you want, not to show that image.. simply choose this page template.
    By going to that page and then click EDIT.. and then in right sidebar.. you have a box
    where you can select THIS NEW PAGE TEMPLATE...

    Let me know if this help or if something does not make sense..i will try to write
    more clearly..

    Regards,
    Mohsin
    • [ 1 ] Thanks
  • Thanks!

    But, I must be blind. Where is the option to change the theme?
    • [2] replies
    • In the wp admin area Go to menu Appearence -> Editor and you will be able to edit the theme directly on the page.
    • No, Mike you do not need to change the theme.

      1. You need to create Custom page template and put in existing theme's folder
      in wp-content/themes/YOURTHEME

      2. Now when you will have a custom page template (NOT a new THEME but in same theme!)
      When you will access any page editing in Wordpress Dashboard...

      in left side you see option to choose CUSTOM page template.

      See this image where this theme has THREE more custom page templates.
      http://ianscott.co.uk/wp-content/upl...ustomTheme.png

      If you still cannot get it resolved. PM me your ftp and wordpress details
      and I do setup one sample custom template for you, so you can follow it onward.

      Keep Rocking Warrior!
      Mohsin
  • Sorry I made you explain it again, I understood the first time :p

    However, I wanted to know if this was possible to do for a single post, NOT a page.

    Sorry for the confusion.
    • [2] replies
    • Well, Mike, you DID ask about pages!!! We will try to answer what you asked....
    • Oh I am sorry i should have not assumed it as PAGES
      Ok i have not used this but i see this plugin adds this missing capability in Wordpress
      WordPress › Custom Post Template « WordPress Plugins

      After this plugin install, posts are supposed to show same custom template panel for Pages!

      Hope this help,
      Mohsin
      PS. Mike please do not forget to update here if this plugin helped in this situation,
      so we know that if this plugin works as it says... it will be good addition to use in next
      project if any client wanted this functionality... !
  • Well, maybe the OP has ben edited/changed later... because now it asks about post and (correctly) single.php!

    You can edit the single.php template file - and my advice always is: NEVER EVER use the idiotic online theme editor:
    1. it leaves your blog vulnerable
    2. it doesn't have an UNDO button!!!

    So, now to the editing: you need to use one of the Conditional Tags of WP.
    Specifically, this: Conditional Tags « WordPress Codex

    you will need to use the if_single('XXX') - where XXX is your post's ID.
  • give this try

    give you the option for post templates the same as the default WordPress gives for pages
    WordPress › Custom Post Template « WordPress Plugins

    (adds the "post template" drop-down box to your post after you create a post template page )

    use

    <?php
    /*
    Template Name Posts: New Template Name
    */
    ?>


    instead of

    <?php
    /*
    Template Name: New Template Name
    */
    ?

Next Topics on Trending Feed

  • 11

    Is there anyway to edit the HTML of a single post on Wordpress? Let's say that I have an image in my single.php that shows up on all of the posts on my site. However, I don't want that image on one of those posts. How can I remove that image from the single post that I don't want it on?